subset_covid | R Documentation |
Subset any of the COVerAGE-DB datasets that is already read into memory.
subset_covid(df, Country, Region, Sex, Date)
df |
|
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. |
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.
The subsetted data frame like object.
Erez Shomron
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.