Identifies data-quality problems in a cleaned AFP table using columns the
cleaner already produced (duplicates, blank keys, unreconciled GUIDs,
missing/zero coordinates, future onset dates, out-of-range age, negative
timeliness intervals, inadequate stool). Checks whose required columns are
absent are listed as not_run, with their missing columns recorded.
Usage
checks_afp(afp, reference_date = Sys.Date())Arguments
- afp
A cleaned AFP tibble (from
clean_afp()).- reference_date
Date treated as "today" for future-date checks (default
Sys.Date()).
Value
A named list: summary (a tibble with one row per configured check:
check, domain, severity, n_flagged, status, missing_columns,
description) followed by one
tibble of flagged rows (key columns) per check that found problems. Pass it
to write_checks_excel() to export a workbook.
Checks without their required columns appear as status = "not_run" and
n_flagged = NA; they are distinct from checks that ran and found no issues.
Examples
afp <- data.frame(
id = c(1, 1), epid = c("A-1", "A-1"),
paralysis_onset_date = c("2024-01-02", "2024-01-02"),
adm0 = "NIGERIA"
)
checks_afp(afp)$summary
#> # A tibble: 9 × 7
#> check domain severity n_flagged status missing_columns description
#> <chr> <chr> <chr> <int> <chr> <chr> <chr>
#> 1 afp_missing_guid AFP error NA not_r… "adm1_guid, ad… Cases miss…
#> 2 afp_duplicates AFP warning 2 check… "" Duplicate …
#> 3 afp_no_onset AFP warning 0 check… "" AFP cases …
#> 4 afp_future_onset AFP warning 0 check… "" Onset date…
#> 5 afp_no_classific… AFP warning NA not_r… "classificatio… AFP cases …
#> 6 afp_negative_int… AFP warning NA not_r… "" Negative t…
#> 7 afp_empty_coords AFP info NA not_r… "latitude, lon… Cases with…
#> 8 afp_age_out_of_r… AFP info NA not_r… "age_months" Age in mon…
#> 9 afp_inadequate_s… AFP info NA not_r… "adequate_stoo… Cases flag…
