
Read survey files from different formats and create a Survey object
Source:R/load_survey.R
load_survey.Rd
Read survey files from different formats and create a Survey object
Usage
load_survey(
path = NULL,
svy_type = NULL,
svy_edition = NULL,
svy_weight = NULL,
svy_psu = NULL,
...,
bake = FALSE,
recipes = NULL
)
Arguments
- path
Survey file path, file can be in different formats, csv, xtsx, dta, sav and rds
- svy_type
String with the survey type, supported types; "ech" (Encuensta Continua de Hogares, Uruguay), "eph" ( Encuesta Permanente de Hogares, Argentina), "eai" (Encuesta de Actividades de Innovación, Uruguay)
- svy_edition
String with survey edition information, support different time patterns: "YYYYMM"/"MMYYYY" (year- month), "YYYY" (year), ("YYYY-YYYY") date range
- svy_weight
List with survey weight information specifing periodicity and the name of the weight variable. Recomended to use the helper function add_weight().
- svy_psu
Primary sampling unit
- ...
Further arguments to be passed to load_survey
- bake
Logical inicating if a recipes is processed when the data are loaded.
- recipes
object, using helper function get_recipes()
Examples
ech_2022 <- load_survey(
metasurvey::load_survey_example(
"ech",
"ech_2022"
),
svy_edition = "2022",
svy_type = "ech",
svy_weight = add_weight(annual = "w_ano"),
recipes = get_recipe(
"ech",
"2022"
)
)
#> The API returned 1 recipes
# Example of loading a survey file
survey <- load_survey(
path = "path/to/survey.csv",
svy_type = "ech",
svy_edition = "2023",
svy_weight = add_weight(annual = "w_ano"),
bake = TRUE
)
#> Error in fread(file = "path/to/survey.csv"): File 'path/to/survey.csv' does not exist or is non-readable. getwd()=='/home/runner/work/metasurvey/metasurvey/docs/reference'
print(survey)
#> Error: object 'survey' not found