subset_covid: Subset COVerAGE-DB Datasets

View source: R/subset_covid.R

subset_covidR Documentation

Subset COVerAGE-DB Datasets

Description

Subset any of the COVerAGE-DB datasets that is already read into memory.

Usage

subset_covid(df, Country, Region, Sex, Date)

Arguments

df

data.frame, data.table, or tbl_df. Expecting a COVerAGE-DB dataset.

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

This function assumes the 'df' argument is one of the COVerAGE-DB datasets, or at least has a similar format. There's no check to test if this input is correct. Missing arguments except 'df' are ignored. The 'Date' argument can be either a character vector of a date, which will be converted to a 'Date' object, or alternatively a 'Date' object, which conversion will be skipped for. Dates are subsetted so the included dates are from the date inputted to the most recent date in the dataset. If multiple dates are passed, only the earliest date is taken into account. Countries that do not have regional data only have "All" set as their region. Subsetting is very fast due to the usage of the collapse package as a backend.

Value

The subsetted data frame like object.

Author(s)

Erez Shomron

Examples

## Not run: 
# Nothing happens
subset_covid(df)
# Select several countries
subset_covid(df, Country = c("USA", "Sweden"))
# Sweden, females only
subset_covid(df, Country = "Sweden", Sex = "f")
# New York City
subset_covid(df, Country = "USA", Region = "New York City")
subset_covid(df, Region = "New York City")
# All countries since "2020-12-01"
subset_covid(df, Date = as.Date("2020-12-01"))
subset_covid(df, Date = "2020-12-01")

## End(Not run)


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