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

merge_waves(waves, var_harmonization)

Arguments

waves

A list of surveys

var_harmonization

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

Value

A list of surveys with harmonized names and variable labels.

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) metadata <- metadata_waves_create(example_surveys) to_harmonize <- metadata %>% dplyr::filter ( var_name_orig %in% c("rowid", "w1") | grepl("trust ", label_orig ) ) %>% dplyr::mutate ( var_label = var_label_normalize(label_orig) ) %>% dplyr::mutate ( var_name = val_label_normalize(var_label) ) merge_waves ( example_surveys, to_harmonize )
#> [[1]] #> # A tibble: 35 x 7 #> unique_identifier~ trust_in_institut~ trust_in_instituti~ trust_in_instituti~ #> <chr> <retroh_dbl> <retroh_dbl> <retroh_dbl> #> 1 ZA5913_1 2 [Tend not to tr~ 2 [Tend not to tru~ 2 [Tend not to tru~ #> 2 ZA5913_2 2 [Tend not to tr~ 2 [Tend not to tru~ 2 [Tend not to tru~ #> 3 ZA5913_3 1 [Tend to trust] 1 [Tend to trust] 1 [Tend to trust] #> 4 ZA5913_4 2 [Tend not to tr~ 1 [Tend to trust] 1 [Tend to trust] #> 5 ZA5913_5 1 [Tend to trust] 1 [Tend to trust] 2 [Tend not to tru~ #> 6 ZA5913_6 1 [Tend to trust] 2 [Tend not to tru~ 2 [Tend not to tru~ #> 7 ZA5913_7 2 [Tend not to tr~ 3 (NA) [DK] 2 [Tend not to tru~ #> 8 ZA5913_8 1 [Tend to trust] 1 [Tend to trust] 1 [Tend to trust] #> 9 ZA5913_9 2 [Tend not to tr~ 2 [Tend not to tru~ 2 [Tend not to tru~ #> 10 ZA5913_10 2 [Tend not to tr~ 2 [Tend not to tru~ 2 [Tend not to tru~ #> # ... with 25 more rows, and 3 more variables: #> # trust_in_institutions_political_parties <retroh_dbl>, #> # trust_in_institutions_reg_loc_authorities <retroh_dbl>, #> # weight_result_from_target <dbl> #> #> [[2]] #> # A tibble: 50 x 15 #> unique_identifier~ trust_in_institut~ trust_in_instituti~ trust_in_instituti~ #> <chr> <retroh_dbl> <retroh_dbl> <retroh_dbl> #> 1 ZA6863_1 1 [Tend to trust] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 2 ZA6863_2 2 [Tend not to tr~ 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 3 ZA6863_3 3 [DK] 3 [DK] 9 (NA) [Inap. (not~ #> 4 ZA6863_4 2 [Tend not to tr~ 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 5 ZA6863_5 3 [DK] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 6 ZA6863_6 2 [Tend not to tr~ 2 [Tend not to tru~ 9 (NA) [Inap. (not~ #> 7 ZA6863_7 1 [Tend to trust] 3 [DK] 9 (NA) [Inap. (not~ #> 8 ZA6863_8 1 [Tend to trust] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 9 ZA6863_9 1 [Tend to trust] 2 [Tend not to tru~ 9 (NA) [Inap. (not~ #> 10 ZA6863_10 1 [Tend to trust] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> # ... with 40 more rows, and 11 more variables: #> # trust_in_institutions_justice_legal_system <retroh_dbl>, #> # trust_in_institutions_national_government <retroh_dbl>, #> # trust_in_institutions_national_parliament <retroh_dbl>, #> # trust_in_institutions_police <retroh_dbl>, #> # trust_in_institutions_political_parties <retroh_dbl>, #> # trust_in_institutions_political_parties_tcc <retroh_dbl>, #> # trust_in_institutions_public_administration <retroh_dbl>, #> # trust_in_institutions_reg_local_public_authorities <retroh_dbl>, #> # trust_in_institutions_united_nations <retroh_dbl>, #> # trust_in_institutions_united_nations_tcc <retroh_dbl>, #> # weight_result_from_target_redressment <dbl> #> #> [[3]] #> # A tibble: 45 x 17 #> unique_identifier~ trust_in_institut~ trust_in_instituti~ trust_in_instituti~ #> <chr> <retroh_dbl> <retroh_dbl> <retroh_dbl> #> 1 ZA7576_1 1 [Tend to trust] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 2 ZA7576_2 1 [Tend to trust] 3 [DK] 9 (NA) [Inap. (not~ #> 3 ZA7576_3 1 [Tend to trust] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 4 ZA7576_4 1 [Tend to trust] 2 [Tend not to tru~ 9 (NA) [Inap. (not~ #> 5 ZA7576_5 1 [Tend to trust] 3 [DK] 9 (NA) [Inap. (not~ #> 6 ZA7576_6 1 [Tend to trust] 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 7 ZA7576_7 1 [Tend to trust] 2 [Tend not to tru~ 9 (NA) [Inap. (not~ #> 8 ZA7576_8 2 [Tend not to tr~ 1 [Tend to trust] 9 (NA) [Inap. (not~ #> 9 ZA7576_9 2 [Tend not to tr~ 2 [Tend not to tru~ 9 (NA) [Inap. (not~ #> 10 ZA7576_10 1 [Tend to trust] 2 [Tend not to tru~ 9 (NA) [Inap. (not~ #> # ... with 35 more rows, and 13 more variables: #> # trust_in_institutions_justice_legal_system <retroh_dbl>, #> # trust_in_institutions_media <retroh_dbl>, #> # trust_in_institutions_media_tcc <retroh_dbl>, #> # trust_in_institutions_national_government <retroh_dbl>, #> # trust_in_institutions_national_parliament <retroh_dbl>, #> # trust_in_institutions_police <retroh_dbl>, #> # trust_in_institutions_political_parties <retroh_dbl>, #> # trust_in_institutions_political_parties_tcc <retroh_dbl>, #> # trust_in_institutions_public_administration <retroh_dbl>, #> # trust_in_institutions_reg_local_public_authorities <retroh_dbl>, #> # trust_in_institutions_united_nations <retroh_dbl>, #> # trust_in_institutions_united_nations_tcc <retroh_dbl>, #> # weight_result_from_target_redressment <dbl> #>
# }