Skip to contents

Merge a list of surveys into a list with harmonized variable names, variable labels and survey identifiers.

Usage

merge_surveys(survey_list, var_harmonization)

merge_waves(waves, var_harmonization)

Arguments

survey_list

A list of surveys

var_harmonization

Metadata of surveys, including at least filename, var_name_orig, var_name_target, var_label.

waves

Deprecated.

Value

A list of surveys with harmonized names and variable labels.

Details

The function was called till version 0.2.0 merge_waves(), which reflects the vocabulary of Eurobarometer surveys.

See also

survey

Examples

# \donttest{
examples_dir <- system.file("examples", package = "retroharmonize")
survey_list <- dir(examples_dir)[grepl("\\.rds", dir(examples_dir))]

example_surveys <- read_surveys(
  file.path( examples_dir, survey_list), 
  save_to_rds = FALSE)
#> Error in read_surveys(file.path(examples_dir, survey_list), save_to_rds = FALSE): unused argument (save_to_rds = FALSE)
    
metadata <- metadata_surveys_create(example_surveys)
#> Error in metadata_surveys_create(example_surveys): could not find function "metadata_surveys_create"
 
require(dplyr)

to_harmonize <- metadata %>%
  filter ( var_name_orig %in% 
             c("rowid", "w1") |
             grepl("^trust", label_orig ) ) %>%
  mutate ( var_label = var_label_normalize(label_orig) ) %>%
  mutate ( var_name_target = val_label_normalize(var_label) ) %>%
  mutate ( var_name_target = ifelse(.data$var_name_orig %in% c("rowid", "w1", "wex"), 
                                    .data$var_name_orig, .data$var_name_target) )
#> Error in filter(., var_name_orig %in% c("rowid", "w1") | grepl("^trust",     label_orig)): object 'metadata' not found

merge_surveys ( example_surveys, to_harmonize )
#> Error in eval(assertion, env): object 'example_surveys' not found
# }