Skip to contents

This function verifies if the difference in dates within each group in the provided observations corresponds to the provided timestep. This check is performed for the specified date_var and for each group in obs.

Usage

check_timestep_by_group(obs, date_var, timestep = "day", exact = 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.

Value

This function is used for its side effect of checking the timestep by group in obs. If the check passes for all groups, the function returns invisibly. Otherwise, it stops and returns an error message.