Read Survey Files

Import surveys into a list. Adds filename as a constant to each element of the list.

read_surveys(import_file_names, .f = "read_rds", save_to_rds = TRUE)

Arguments

import_file_names

A vector of file names to import.

.f

A function to import the surveys with. Defaults to 'read_rds'. For SPSS files, read_spss is recommended, which is a well-parameterized version of read_spss that saves some metadata, too.

save_to_rds

Should it save the imported survey to .rds? Defaults to TRUE.

Value

A list of the surveys. Each element of the list is a data frame-like survey type object where some metadata, such as the original file name, doi identifier if present, and other information is recorded for a reproducible workflow.

See also

survey

Other import functions: pull_survey(), read_rds(), read_spss(), subset_save_surveys()

Examples

file1 <- system.file( "examples", "ZA7576.rds", package = "retroharmonize") file2 <- system.file( "examples", "ZA5913.rds", package = "retroharmonize") read_surveys (c(file1,file2), .f = 'read_rds' )
#> [[1]] #> # A tibble: 45 x 56 #> rowid doi version uniqid caseid serialid isocntry p1 p2 p3 #> * <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <dbl+lb> <dbl+l> <dbl> #> 1 ZA75~ doi:~ 1.0.0 ~ 5.00e7 481 3209 ES 4 [Mon~ 3 [13 ~ 25 #> 2 ZA75~ doi:~ 1.0.0 ~ 1.10e8 76 8706 NL 6 [Wed~ 3 [13 ~ 58 #> 3 ZA75~ doi:~ 1.0.0 ~ 1.10e8 343 8890 NL 11 [Mon~ 3 [13 ~ 56 #> 4 ZA75~ doi:~ 1.0.0 ~ 1.10e8 473 8989 NL 5 [Tue~ 3 [13 ~ 62 #> 5 ZA75~ doi:~ 1.0.0 ~ 1.10e8 493 9001 NL 8 [Fri~ 4 [17 ~ 30 #> 6 ZA75~ doi:~ 1.0.0 ~ 1.10e8 897 9272 NL 6 [Wed~ 3 [13 ~ 56 #> 7 ZA75~ doi:~ 1.0.0 ~ 1.10e8 1041 9379 NL 5 [Tue~ 3 [13 ~ 57 #> 8 ZA75~ doi:~ 1.0.0 ~ 1.10e8 1192 9493 NL 6 [Wed~ 2 [8 -~ 60 #> 9 ZA75~ doi:~ 1.0.0 ~ 1.10e8 1274 9543 NL 7 [Thu~ 4 [17 ~ 57 #> 10 ZA75~ 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>, d8 <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> #> #> [[2]] #> # A tibble: 35 x 38 #> rowid doi version uniqid isocntry p1 p3 p4 p5 nuts #> * <chr> <chr> <chr> <dbl> <chr> <dbl+lb> <dbl> <dbl+l> <dbl+l> <chr+lbl> #> 1 ZA59~ doi:~ 2.0.0 ~ 1.13e7 NL 8 [Tue~ 27 1 [Two~ 1 [Exc~ N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