coerce_date: Coerce Dates

coerce_dateR Documentation

Coerce Dates

Description

Provides consistent coercion of inputs to IDate with error handling

Usage

coerce_date(dates = NULL)

Arguments

dates

A vector-like input, which the function attempts to coerce via data.table::as.IDate(). Defaults to NULL.

Details

If any of the elements of dates cannot be coerced, this function will result in an error, indicating all indices which cannot be coerced to IDate.

Internal methods of epinowcast assume dates are represented as IDate.

Value

An IDate vector.

See Also

Utility functions aggregate_rolling_sum(), coerce_dt(), date_to_numeric_modulus(), get_internal_timestep(), is.Date(), stan_fns_as_string()

Examples

# works
coerce_date(c("2020-05-28", "2020-05-29"))
# does not, indicates index 2 is problem
tryCatch(
  coerce_date(c("2020-05-28", "2020-o5-29")),
  error = function(e) {
    print(e)
  }
)

seabbs/epinowcast documentation built on Sept. 20, 2024, 2:39 a.m.