Learn R Programming

contactsurveys (version 0.1.0)

download_survey: Download a survey from its Zenodo repository

Description

Downloads survey data. Uses a caching mechanism via the default argument for directory.

Usage

download_survey(
  survey,
  directory = tempdir(),
  verbose = TRUE,
  overwrite = FALSE,
  timeout = 3600,
  rate = purrr::rate_backoff(pause_base = 5, max_times = 4)
)

Value

a vector of filenames, where the surveys were downloaded

Arguments

survey

A DOI of a survey, (see list_surveys()). If a HTML link is given, the DOI will be isolated and used.

directory

Directory of where to save survey files. Defaults to tempdir(), so files do not persist across R sessions. For persistent caching, pass contactsurveys_dir(), which uses tools::R_user_dir() and appends the survey URL/DOI basename as a subdirectory. E.g., if you provide "10.5281/zenodo.1095664" in the survey argument, it will save the surveys into a directory zenodo.1095664 under contactsurveys_dir(). You can also set an environment variable, CONTACTSURVEYS_HOME, see Sys.setenv() or Renviron for more detail.

verbose

Whether downloads should be echoed to output. Default TRUE.

overwrite

If files should be overwritten if they already exist. Default FALSE

timeout

A numeric value specifying timeout in seconds. Default 3600 seconds.

rate

a purrr rate object, to facilitate downloading if the download fails. Defaults to an exponential backoff of 5 seconds (up to 4 attempts: 1 initial + 3 retries) changed by specifying your own rate object, see ?purrr::rate_backoff() for details.

See Also

list_surveys()

Examples

Run this code
# \donttest{
list_surveys()
peru_survey <- download_survey("https://doi.org/10.5281/zenodo.1095664")
# }

Run the code above in your browser using DataLab