Checks whether a vector of dates forms a complete, uninterrupted sequence
between its minimum and maximum values. If missing dates are detected,
they are printed using dput() for easy reuse and the function returns
FALSE invisibly.
Arguments
- x
Date A vector of dates to check for completeness.
- units
character Optional. A single string giving the time unit for the sequence passed to
base::seq.Date(). Default is"days".- dates_print
logical Optional. Whether to print missing dates to the console using
dput()when gaps are detected. Default isTRUE.- dates_capture
logical Optional. Whether to capture and return the missing dates as an object when gaps are detected. Default is
FALSE.
Value
If dates_capture = FALSE (default), returns TRUE invisibly if no dates
are missing and FALSE invisibly if one or more dates are missing.
If dates_capture = TRUE, returns the missing dates as a Date vector
(invisibly) when gaps are detected, and TRUE invisibly when no dates
are missing.
Details
The function computes a full date sequence using base::seq.Date() from
min(x) to max(x) and compares it to the unique values of x using
base::setdiff(). Missing dates, if any, are printed with dput() so they
can be copied directly into code or tests.
See also
Other chk:
ngr_chk_coerce_date()