The function harmonizes the variable names of surveys (of class survey) that are imported from an external file as a wave.

harmonize_var_names(waves, metadata, rowids = TRUE)

Arguments

waves

A list of surveys imported with read_surveys.

metadata

A metadata table created by metadata_create and binded together for all surveys in waves.

rowids

Rename var labels of original vars rowid to simply uniqid?

Value

The list of surveys with harmonized variable names.

See also

Examples

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 <- lapply ( X = example_surveys, FUN = metadata_create ) metadata <- do.call(rbind, metadata) metadata$var_name <- label_normalize(metadata$var_name) metadata$var_name [metadata$label_orig == "age education"] <- "age_education" harmonize_var_names(waves = example_surveys, metadata = metadata )
#> [[1]] #> # A tibble: 35 x 38 #> uniqid doi version uniqid isocntry p1 p3 p4 p5 #> * <chr> <chr> <chr> <dbl> <chr> <dbl+lb> <dbl> <dbl+l> <dbl+l> #> 1 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 8 [Tue~ 27 1 [Two~ 1 [Exc~ #> 2 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 8 [Tue~ 31 1 [Two~ 1 [Exc~ #> 3 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 10 [Thu~ 26 1 [Two~ 1 [Exc~ #> 4 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 14 [Mon~ 23 1 [Two~ 1 [Exc~ #> 5 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 10 [Thu~ 31 2 [Thr~ 1 [Exc~ #> 6 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 8 [Tue~ 33 1 [Two~ 1 [Exc~ #> 7 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 10 [Thu~ 21 1 [Two~ 1 [Exc~ #> 8 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 10 [Thu~ 44 1 [Two~ 1 [Exc~ #> 9 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 5 [Sat~ 19 1 [Two~ 2 [Fai~ #> 10 ZA591~ doi:~ 2.0.0 ~ 1.13e7 NL 14 [Mon~ 22 1 [Two~ 1 [Exc~ #> # ... with 25 more rows, and 29 more variables: nuts <chr+lbl>, d7 <dbl+lbl>, #> # age_education <dbl+lbl>, d25 <dbl+lbl>, d60 <dbl+lbl>, qa10_3 <dbl+lbl>, #> # qa10_2 <dbl+lbl>, qa10_1 <dbl+lbl>, qa7_4 <dbl+lbl>, qa7_2 <dbl+lbl>, #> # qa7_3 <dbl+lbl>, qa7_1 <dbl+lbl>, qa7_5 <dbl+lbl>, qd3_1 <dbl+lbl>, #> # qd3_2 <dbl+lbl>, qd3_3 <dbl+lbl>, qd3_4 <dbl+lbl>, qd3_5 <dbl+lbl>, #> # qd3_6 <dbl+lbl>, qd3_7 <dbl+lbl>, qd3_8 <dbl+lbl>, qd3_9 <dbl+lbl>, #> # qd3_10 <dbl+lbl>, qd3_11 <dbl+lbl>, qd3_12 <dbl+lbl>, qd3_13 <dbl+lbl>, #> # qd3_14 <dbl+lbl>, w1 <dbl>, w3 <dbl> #> #> [[2]] #> # A tibble: 50 x 49 #> uniqid doi version uniqid serialid isocntry p1 p2 p3 p4 #> * <chr> <chr> <chr> <dbl> <dbl> <chr> <dbl+l> <dbl+l> <dbl> <dbl+l> #> 1 ZA686~ doi:~ 1.0.0 ~ 1.10e8 8688 NL 7 [Fri~ 2 [8 -~ 50 1 [Two~ #> 2 ZA686~ doi:~ 1.0.0 ~ 1.10e8 8890 NL 5 [Wed~ 4 [17 ~ 50 1 [Two~ #> 3 ZA686~ doi:~ 1.0.0 ~ 1.10e8 8925 NL 5 [Wed~ 4 [17 ~ 65 1 [Two~ #> 4 ZA686~ doi:~ 1.0.0 ~ 1.10e8 8939 NL 4 [Tue~ 2 [8 -~ 47 1 [Two~ #> 5 ZA686~ doi:~ 1.0.0 ~ 1.10e8 9035 NL 3 [Mon~ 5 [20 ~ 49 2 [Thr~ #> 6 ZA686~ doi:~ 1.0.0 ~ 1.10e8 9188 NL 3 [Mon~ 5 [20 ~ 57 1 [Two~ #> 7 ZA686~ doi:~ 1.0.0 ~ 1.10e8 9429 NL 3 [Mon~ 2 [8 -~ 52 1 [Two~ #> 8 ZA686~ doi:~ 1.0.0 ~ 1.10e8 9450 NL 5 [Wed~ 3 [13 ~ 58 1 [Two~ #> 9 ZA686~ doi:~ 1.0.0 ~ 1.10e8 9570 NL 6 [Thu~ 4 [17 ~ 39 1 [Two~ #> 10 ZA686~ doi:~ 1.0.0 ~ 1.10e8 9674 NL 7 [Fri~ 3 [13 ~ 41 1 [Two~ #> # ... with 40 more rows, and 39 more variables: p5 <dbl+lbl>, nuts <chr+lbl>, #> # d7 <dbl+lbl>, age_education <dbl+lbl>, d25 <dbl+lbl>, d60 <dbl+lbl>, #> # qa14_3 <dbl+lbl>, qa14_2 <dbl+lbl>, qa14_1 <dbl+lbl>, qa8a_3 <dbl+lbl>, #> # qa8a_9 <dbl+lbl>, qa8b_2 <dbl+lbl>, qa8a_1 <dbl+lbl>, qa8a_7 <dbl+lbl>, #> # qa8a_8 <dbl+lbl>, qa8a_2 <dbl+lbl>, qa8a_5 <dbl+lbl>, qa8b_1 <dbl+lbl>, #> # qa8a_4 <dbl+lbl>, qa8a_6 <dbl+lbl>, qa8a_10 <dbl+lbl>, qa8b_3 <dbl+lbl>, #> # `qd7 1` <dbl+lbl>, `qd7 2` <dbl+lbl>, `qd7 3` <dbl+lbl>, `qd7 4` <dbl+lbl>, #> # `qd7 5` <dbl+lbl>, `qd7 6` <dbl+lbl>, `qd7 7` <dbl+lbl>, `qd7 8` <dbl+lbl>, #> # `qd7 9` <dbl+lbl>, `qd7 10` <dbl+lbl>, `qd7 11` <dbl+lbl>, `qd7 #> # 12` <dbl+lbl>, `qd7 13` <dbl+lbl>, `qd7 14` <dbl+lbl>, w1 <dbl>, w3 <dbl>, #> # wex <dbl> #> #> [[3]] #> # A tibble: 45 x 56 #> uniqid doi version uniqid caseid serialid isocntry p1 p2 p3 #> * <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <dbl+lb> <dbl+l> <dbl> #> 1 ZA757~ doi:~ 1.0.0 ~ 5.00e7 481 3209 ES 4 [Mon~ 3 [13 ~ 25 #> 2 ZA757~ doi:~ 1.0.0 ~ 1.10e8 76 8706 NL 6 [Wed~ 3 [13 ~ 58 #> 3 ZA757~ doi:~ 1.0.0 ~ 1.10e8 343 8890 NL 11 [Mon~ 3 [13 ~ 56 #> 4 ZA757~ doi:~ 1.0.0 ~ 1.10e8 473 8989 NL 5 [Tue~ 3 [13 ~ 62 #> 5 ZA757~ doi:~ 1.0.0 ~ 1.10e8 493 9001 NL 8 [Fri~ 4 [17 ~ 30 #> 6 ZA757~ doi:~ 1.0.0 ~ 1.10e8 897 9272 NL 6 [Wed~ 3 [13 ~ 56 #> 7 ZA757~ doi:~ 1.0.0 ~ 1.10e8 1041 9379 NL 5 [Tue~ 3 [13 ~ 57 #> 8 ZA757~ doi:~ 1.0.0 ~ 1.10e8 1192 9493 NL 6 [Wed~ 2 [8 -~ 60 #> 9 ZA757~ doi:~ 1.0.0 ~ 1.10e8 1274 9543 NL 7 [Thu~ 4 [17 ~ 57 #> 10 ZA757~ doi:~ 1.0.0 ~ 1.10e8 1344 9590 NL 6 [Wed~ 2 [8 -~ 83 #> # ... with 35 more rows, and 46 more variables: p4 <dbl+lbl>, p5 <dbl+lbl>, #> # nuts <chr+lbl>, d7 <dbl+lbl>, age_education <dbl+lbl>, d25 <dbl+lbl>, #> # d60 <dbl+lbl>, qa14_5 <dbl+lbl>, qa14_3 <dbl+lbl>, qa14_2 <dbl+lbl>, #> # qa14_4 <dbl+lbl>, qa14_1 <dbl+lbl>, qa6a_5 <dbl+lbl>, qa6a_10 <dbl+lbl>, #> # qa6b_2 <dbl+lbl>, qa6a_3 <dbl+lbl>, qa6a_1 <dbl+lbl>, qa6b_4 <dbl+lbl>, #> # qa6a_8 <dbl+lbl>, qa6a_9 <dbl+lbl>, qa6a_4 <dbl+lbl>, qa6a_2 <dbl+lbl>, #> # qa6b_1 <dbl+lbl>, qa6a_6 <dbl+lbl>, qa6a_7 <dbl+lbl>, qa6a_11 <dbl+lbl>, #> # qa6b_3 <dbl+lbl>, `qd6 1` <dbl+lbl>, `qd6 2` <dbl+lbl>, `qd6 3` <dbl+lbl>, #> # `qd6 4` <dbl+lbl>, `qd6 5` <dbl+lbl>, `qd6 6` <dbl+lbl>, `qd6 7` <dbl+lbl>, #> # `qd6 8` <dbl+lbl>, `qd6 9` <dbl+lbl>, `qd6 10` <dbl+lbl>, `qd6 #> # 11` <dbl+lbl>, `qd6 12` <dbl+lbl>, `qd6 13` <dbl+lbl>, `qd6 14` <dbl+lbl>, #> # qg1b <dbl+lbl>, qg8 <dbl+lbl>, w1 <dbl>, w3 <dbl>, wex <dbl> #>