subset_save_surveys: Subset and Save Surveys

Description Usage Arguments Value See Also Examples

Description

Read a predefined survey list and variables.

Usage

1
2
3
4
5
6
subset_save_surveys(
  var_harmonization,
  selection_name = "trust",
  import_path = "",
  export_path = "working"
)

Arguments

var_harmonization

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

selection_name

An identifier for the survey subset.

import_path

The path to the survey files.

export_path

The path where the subsets should be saved.

Value

The function does not return a value. It saves the subsetted surveys into .rds files.

See Also

Other import functions: pull_survey(), read_dta(), read_rds(), read_spss(), read_surveys()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
test_survey <- read_rds (
 file = system.file("examples", "ZA7576.rds",
                    package = "retroharmonize")
)

test_metadata <- metadata_create ( test_survey )
test_metadata <- test_metadata[c(18:37),]
test_metadata$var_name  <- var_label_normalize (test_metadata$var_name_orig)
test_metadata$var_label <- test_metadata$label_orig

saveRDS(test_survey, file.path(tempdir(), 
                              "ZA7576.rds"), 
       version = 2)

subset_save_surveys  ( var_harmonization = test_metadata, 
                      selection_name = "tested",
                      import_path = tempdir(), 
                      export_path = tempdir())

file.exists ( file.path(tempdir(), "ZA7576_tested.rds"))

retroharmonize documentation built on Nov. 3, 2021, 1:07 a.m.