Used to check vectors of dates mainly to ensure that weather data are
complete. Invisibly returns a NULL value if no problems are found, else
issues a warning() with an informative message providing the user with
missing date values in the sequence and the optional location name if it's
provided. Errors if x is empty or contains NA values.
Value
An invisible NULL, called for its side-effects. Warns if dates
are not sequential (some are missing), are unsorted or are duplicated.
Author
Adam H. Sparks, adamhsparks@gmail.com
Examples
# passes
x <- seq(as.Date("2021-01-01"), as.Date("2021-01-31"), by = "1 day")
y <- "BA"
check_date_seq(x = x, y = y)
# warns
x <- c(
seq(as.Date("2021-01-01"), as.Date("2021-01-31"), by = "1 day"),
seq(as.Date("2021-02-02"), as.Date("2021-02-28"), by = "1 day")
)
y <- "BA"
check_date_seq(x = x, y = y)
#> Warning: ✖ The vectors do not contain sequential dates.
#> ℹ 2021-02-01 is/are missing for location BA.