read_subset_covid: Read a subset of a COVerAGE-DB dataset

View source: R/read_subset_covid.R

read_subset_covidR Documentation

Read a subset of a COVerAGE-DB dataset

Description

Lazily reads a subset of a locally saved COVerAGE-DB dataset. Data manipulation is handled lazily.

Usage

read_subset_covid(
  zippath,
  data = c("inputDB", "Output_5", "Output_10", "qualityMetrics"),
  return = c("data.frame", "data.table", "tibble"),
  Country,
  Region,
  Sex,
  Date
)

Arguments

zippath

Character. The local zip archive of the downloaded dataset.

data

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

return

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

Country

Character vector of countries to select.

Region

Character vector of regions to select.

Sex

Character vector of sexes to select. Usually either 'b' for both. 'f' for females, and 'm' for males.

Date

Either a character or Date vector of dates to include. If a character vector.

Details

The function uses vroom as backend for reading the dataset lazily. The result of this is a memory efficient processing of the data. This approach tends to be slower than reading the whole dataset in memory. Nevertheless, the cost in speed is advantageous to be able to work with very large datasets, or to generally conserve memory the R process uses. Specifically, this is useful for reading the 'inputDB' dataset, which currently holds millions of rows.

Value

By default a data frame with the subsetted dataset. Can be set to return either a data table or a tibble. The return type is controlled by the 'return' parameter.

Author(s)

Erez Shomron


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