check_timestep: Check timestep

check_timestepR Documentation

Check timestep

Description

This function verifies if the difference in dates in the provided observations corresponds to the provided timestep. If the exact argument is set to TRUE, the function checks if all differences exactly match the timestep; otherwise, it checks if the sum of the differences modulo the timestep equals zero. If the check fails, the function stops and returns an error message.

Usage

check_timestep(
  obs,
  date_var,
  timestep = "day",
  exact = TRUE,
  check_nrow = TRUE
)

Arguments

obs

Any of the types supported by data.table::as.data.table().

date_var

The variable in obs representing dates.

timestep

The timestep to used. This can be a string ("day", "week", "month") or a numeric whole number representing the number of days.

exact

Logical, if ⁠TRUE``, checks if all differences exactly match the timestep. If ⁠FALSE“, checks if the sum of the differences modulo the timestep equals zero. Default is TRUE.

check_nrow

Logical, if TRUE, checks if there are at least two observations. Default is TRUE. If FALSE, the function returns invisibly if there is only one observation.

Value

This function is used for its side effect of stopping if the check fails. If the check passes, the function returns invisibly.

See Also

Functions used for checking inputs check_calendar_timestep(), check_group(), check_group_date_unique(), check_max_delay(), check_module(), check_modules_compatible(), check_numeric_timestep(), check_observation_indicator(), check_quantiles(), check_timestep_by_date(), check_timestep_by_group()


seabbs/epinowcast documentation built on July 8, 2024, 1:45 a.m.