assert that a date corresponds to a given epidemiological week and year, according to the given epiweek standard.
Source:R/epiweek.R
assert_date_in_epiweek.Rd
assert that a date corresponds to a given epidemiological week and year, according to the given epiweek standard.
Examples
assert_date_in_epiweek("2025-01-02", 1, 2025, "USA")
assert_date_in_epiweek(
c("2024-12-27", "2025-01-05"),
c(52, 1),
c(2024, 2025),
"ISO"
)
tryCatch(
assert_date_in_epiweek(
"2024-12-01", 52, 2024, "ISO"
),
error = \(e) print(e)
)
#> <error/rlang_error>
#> Error in `assert_date_in_epiweek()`:
#> ! Date(s) '2024-12-01' failed epiweek validation! Did not obtain the
#> user-requested values for `expected_epiweek` and `expected_epiyear` when
#> passed to the epiweek and epiyear functions corresponding to epiweek standard
#> 'ISO'
#> ---
#> Backtrace:
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 4. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. └─forecasttools::assert_date_in_epiweek("2024-12-01", 52, 2024, "ISO")