Checks the input of one indicator for too few rows, a missing reference column,
and a newest period older than expect_latest. It returns a verdict, and the
caller decides what to do.
Usage
qc_surveillance_data_v1(
d,
reference_col = "isoyearweek_reference",
expect_latest = NULL,
min_rows = 1L
)Value
A list with ok, TRUE when every check passes, and reasons, a
character vector that is empty when ok is TRUE.
Details
The checks run in that order and stop at the first failure, so reasons has at
most one entry.
See also
vignette("pipeline", package = "csalert"), section 9.
Other quality control functions:
compare_results(),
qc_week_over_week_v1()
Examples
d <- data.table::data.table(
isoyearweek_reference = c("2023-01", "2023-02"),
numerator = c(10, 12)
)
qc_surveillance_data_v1(d)
#> $ok
#> [1] TRUE
#>
#> $reasons
#> character(0)
#>
# the feed has not been updated as far as the caller expected
qc_surveillance_data_v1(d, expect_latest = "2023-05")
#> $ok
#> [1] FALSE
#>
#> $reasons
#> [1] "latest reference 2023-02 < expected 2023-05 (feed not updated)"
#>
# nothing arrived at all
qc_surveillance_data_v1(d[0])
#> $ok
#> [1] FALSE
#>
#> $reasons
#> [1] "no data (or fewer rows than min_rows)"
#>
