read_surveys: Read survey file(s)

read_surveysR Documentation

Read survey file(s)

Description

Import surveys into a list or several .rds files.

Usage

read_surveys(survey_paths, .f = NULL, export_path = NULL)

read_survey(file_path, .f = NULL, export_path = NULL)

Arguments

survey_paths

A vector of (full) file paths that contain the surveys to import.

.f

A function to import the surveys with. Defaults to 'NULL', in this case files with an extension of '.sav' and '.por' will call case read_spss, files with an extension of '.dta' will call read_dta, rds will call read_rds and '.csv' read_csv.

export_path

Defaults to NULL, in this case the read surveys are imported into a single list of surveys in memory. If export_path is a valid directory, it will instead save each survey an R object with base::saveRDS.

Details

Use read_survey for a single survey and read_surveys for several surveys in in a loop. The function handle exceptions with wrong file names and not readable files. If a file cannot be read, a message is printed, and empty survey is added to the the list in the place of this file.

Value

A list of the surveys or a vector of the saved file names. 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_csv(), read_dta(), read_rds(), read_spss()

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' )

antaldaniel/retroharmonize documentation built on Dec. 11, 2023, 10:49 p.m.