Learn R Programming

socialmixr (version 0.4.0)

get_survey: Get a survey, either from its Zenodo repository, a set of files, or a survey variable

Description

Downloads survey data, or extracts them from files, and returns a clean data set. If a survey URL is accessed multiple times, the data will be cached (unless clear_cache is set to TRUE) to avoid repeated downloads.

Usage

get_survey(survey, clear_cache = FALSE, ...)

Value

a survey in the correct format

Arguments

survey

a DOI or url to get the survey from, or a survey() object (in which case only cleaning is done).

clear_cache

logical, whether to clear the cache before downloading the survey; by default, the cache is not cleared and so multiple calls of this function to access the same survey will not result in repeated downloads

...

options for clean(), which is called at the end of this

Details

If survey objects are used repeatedly the downloaded files can be saved and reloaded between sessions then survey objects can be saved/loaded using base::saveRDS() and base::readRDS(), or via the individual survey files that can be downloaded using download_survey() and subsequently loaded using load_survey().

Examples

Run this code
if (FALSE) {
list_surveys()
peru_survey <- get_survey("https://doi.org/10.5281/zenodo.1095664")
}

Run the code above in your browser using DataLab