download_covid: Download COVerAGE-DB data

View source: R/download_covid.R

download_covidR Documentation

Download COVerAGE-DB data

Description

Downloads one of the COVerAGE-DB datasets hosted on OSF. It reads the downloaded data and converts it into a data frame.

Usage

download_covid(
  data = c("inputDB", "Output_5", "Output_10", "qualityMetrics"),
  dest = getwd(),
  temp = FALSE,
  download_only = FALSE,
  return = c("data.frame", "data.table", "tibble"),
  progress = TRUE,
  conflicts = "overwrite",
  recurse = FALSE,
  verbose = FALSE,
  ...
)

download_covid_version(
  data = c("inputDB", "Output_5", "Output_10", "qualityMetrics"),
  version,
  dest = getwd(),
  temp = FALSE,
  download_method = "auto",
  download_only = FALSE,
  return = c("data.frame", "data.table", "tibble"),
  progress = TRUE,
  ...
)

Arguments

data

The name of the dataset to download. Can be one of the the following: "inputDB", "Output_5", "Output_10", "qualityMetrics".

dest

Character. If 'temp' is set to FALSE, specifies the directory the dataset should be downloaded to. By default, the current working directory.

temp

Logical. Should the dataset be downloaded to a temporary directory?

download_only

Logical. Should the dataset be downloaded without reading it

return

What should be the return type? Can be on of the following: "data.frame", "data.table", "tibble".

progress

Passed to osfr::osf_download(). Logical, if TRUE progress bars are displayed for each file transfer. Mainly useful for transferring large files. For tracking lots of small files, setting ‘verbose = TRUE’ is more informative. For download_covid_version() this is passed instead to utils::download.file()

conflicts

Passed to osfr::osf_download(). This determines what happens when a file with the same name exists at the specified destination. Can be one of the following:

  • ‘"error"’ (the default): throw an error and abort the file transfer operation.

  • ‘"skip"’: skip the conflicting file(s) and continue transferring the remaining files.

  • ‘"overwrite"’: replace the existing file with the transferred copy.

recurse

Passed to osfr::osf_download(). Applies only to OSF directories. If TRUE, a directory is fully recursed and all nested files and subdirectories are downloaded. Alternatively, a positive number will determine the number of levels to recurse.

verbose

Passed to osfr::osf_download() Logical, indicating whether to print informative messages about interactions with the OSF API (default FALSE).

...

Additional named arguments passed to data.table::fread()

version

Integer. Which file version to download?

download_method

Passed to utils::download.file(). Method to be used for downloading files. Current download methods are ‘"internal"’, ‘"wininet"’ (Windows only) ‘"libcurl"’, ‘"wget"’ and ‘"curl"’, and there is a value ‘"auto"’: see ‘Details’ and ‘Note’.

Details

These functions use the OSF API to download the publicly available COVerAGE-DB datasets. It then returns the downloaded dataset as a data frame, data table, or tibble. download_covid() Uses the osfr package as a backend. download_covid_version() uses utils::download.file() to download the specific requested file version. There are 4 possible datasets available for download: "inputDB", "Output_5", "Output_10", "qualityMetrics". See https://timriffe.github.io/covid_age/GettingStarted.html for more information about these datasets.

If the download times out, consider increasing the 'timeout' option in options()

Value

By default a data frame with the uncompressed dataset. Can be set to return either a data table or a tibble. The return type is controlled by the 'return' parameter. If 'download_only' is set to TRUE, the function will invisibly return NULL after downloading the dataset.

Author(s)

Erez Shomron

See Also

osfr::osf_retrieve() for the OSF entity retrieval function; osfr::osf_download() for the downloading function; data.table::fread() for the reading function.

Examples

## Not run: 
# Basic usage
df <- download_covid("inputDB")
# Download data to the working directory.
df <- download_covid("Output_5", temp = FALSE)
# If you want a tibble instead of a data frame:
df <- download_covid("Output_10", return = "tibble")
# Get the first 'inputDB' version
df <- download_covid_version("InputDB", version = 1)

## End(Not run)


eshom/covid-age-data documentation built on May 1, 2022, 12:22 a.m.