Skip to contents

Counts the environmental samples collected in each month up to as_of and the share of them that carry a laboratory classification. A sample still at the laboratory has no classification and is unresolved. A negative sample has a classification but no virus type, so it counts as resolved.

Usage

calc_es_resolution(samples, as_of = Sys.Date(), cols = list())

Arguments

samples

Cleaned environmental samples, one row per sample, as returned by clean_es().

as_of

The reporting date, as a Date or a string that as.Date() reads. Defaults to Sys.Date(). Samples collected after it, or with no collection date, are left out.

cols

Named list overriding the default column names, keyed by table, in the same shape as in calc_polio_indicators(), for example list(samples = list(vtype = "virus_type")). The samples defaults are the polished ES columns, with site_name = "site_name", plus vtype = "vtype", site_guid = "site_guid", longitude = "site_x_coordinate", latitude = "site_y_coordinate" and district_key = "adm2_guid", the column samples are counted by district on.

Value

A tibble with one row per collection month, sorted by month: month (the first day of the month), samples, resolved, pending and resolved_share (resolved over samples, on a scale of 0 to 1).

Examples

es <- tibble::tibble(
  collection_date = as.Date(c("2024-01-05", "2024-01-20", "2024-02-03")),
  classification_all = c("NPEV", NA, "NEGATIVE")
)
calc_es_resolution(es, as_of = as.Date("2024-03-01"))
#> # A tibble: 2 × 5
#>   month      samples resolved pending resolved_share
#>   <date>       <int>    <int>   <int>          <dbl>
#> 1 2024-01-01       2        1       1            0.5
#> 2 2024-02-01       1        1       0            1