| read_surveys | R Documentation |
Import one or more survey files using a consistent survey import interface.
read_surveys(
survey_paths,
.f = NULL,
export_path = NULL,
ids = NULL,
dois = NULL,
...
)
survey_paths |
A character vector of paths to survey files. |
.f |
An import function, a supported import function name, or 'NULL' for automatic format detection. |
export_path |
Optional directory where imported surveys are saved as RDS files. |
ids |
Optional character vector of survey identifiers, with one element per supplied file. |
dois |
Optional character vector of DOI identifiers, with one element per supplied file. |
... |
Additional arguments passed to the import function. |
When '.f' is 'NULL', the import function is selected automatically from the file extension, regardless of case.
The supported formats and corresponding import functions are:
[read_spss()]
[read_dta()]
[read_rds()]
[read_csv()]
Alternatively, supply a supported import function name or a function object through '.f'.
Custom import functions must accept a file path as their first argument and return a survey object. Additional arguments are forwarded to the import function.
Missing files are excluded with a warning. If none of the supplied files exist, an error is raised.
Errors raised during import are reported and a 'NULL' element is returned for the affected file.
When 'export_path' is supplied, imported surveys are saved using [base::saveRDS()]. If the export directory does not exist, the survey is returned in memory with a warning.
A list containing one element per existing input file.
When 'export_path' is 'NULL', the elements are [survey()] or [survey_df()] objects.
When export succeeds, the corresponding list elements contain the exported RDS filenames.
Import errors may result in 'NULL' elements.
[survey()], [survey_df()], [read_rds()], [read_spss()], [read_dta()], [read_csv()]
Other import functions:
harmonize_survey_variables(),
pull_survey(),
read_csv(),
read_dta(),
read_rds(),
read_spss()
examples_dir <- system.file(
"examples",
package = "retroharmonize"
)
survey_files <- list.files(
examples_dir,
pattern = "\\.rds$",
full.names = TRUE
)
surveys <- read_surveys(survey_files)
surveys <- read_surveys(
survey_files,
.f = "read_rds"
)
surveys <- read_surveys(
survey_files,
.f = read_rds
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.