
Filter surveillance data by standard epidemiological dimensions
Source:R/util_mandatory_db_filter.R
mandatory_db_filter.RdApplies a set of standard include/exclude filters to a database table or
data frame using the conventional surveillance field names. Each NULL
argument is a no-op, so callers only need to supply the dimensions they
actually want to restrict.
Usage
mandatory_db_filter(
.data,
granularity_time = NULL,
granularity_time_not = NULL,
granularity_geo = NULL,
granularity_geo_not = NULL,
country_iso3 = NULL,
location_code = NULL,
age = NULL,
age_not = NULL,
sex = NULL,
sex_not = NULL
)Arguments
- .data
A data frame,
data.table, or remote database table (e.g. the result ofdplyr::tbl()) that contains the standard surveillance columns.- granularity_time
Character vector. Values of
granularity_timeto keep.NULL(default) applies no filter.- granularity_time_not
Character vector. Values of
granularity_timeto drop.NULL(default) applies no filter.- granularity_geo
Character vector. Values of
granularity_geoto keep.NULL(default) applies no filter.- granularity_geo_not
Character vector. Values of
granularity_geoto drop.NULL(default) applies no filter.- country_iso3
Character vector. Values of
country_iso3to keep.NULL(default) applies no filter.- location_code
Character vector. Values of
location_codeto keep.NULL(default) applies no filter.- age
Character vector. Values of
ageto keep.NULL(default) applies no filter.- age_not
Character vector. Values of
ageto drop.NULL(default) applies no filter.- sex
Character vector. Values of
sexto keep.NULL(default) applies no filter.- sex_not
Character vector. Values of
sexto drop.NULL(default) applies no filter.
Examples
if (FALSE) { # \dontrun{
# Inside a data_selector function, filter a remote table before collecting:
d <- schema$anon_covid_cases$tbl() |>
mandatory_db_filter(
granularity_time = "isoweek",
granularity_geo = "county",
age_not = "total"
) |>
dplyr::collect()
} # }