merge_waves: Merge waves

Description Usage Arguments Value See Also Examples

View source: R/merge_waves.R

Description

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

Usage

1
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

Other harmonization functions: collect_val_labels(), harmonize_na_values(), harmonize_values(), harmonize_var_names(), harmonize_waves(), label_normalize(), na_range_to_values(), suggest_permanent_names(), suggest_var_names()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)
 
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 )

retroharmonize documentation built on June 27, 2021, 5:06 p.m.