Used to check vectors of dates mainly to ensure that weather data are complete. Invisibly returns a NULL value if no errors 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.

check_date_seq(x, y = NULL)

Arguments

x

A vector of dates.

y

A vector of values with location name, used for warning message.

Value

No return value, called for side effects. Errors if the dates provided are not sequential.

Author

Adam H. Sparks, adam.sparks@dpird.wa.gov.au

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)
#> Warning: The vectors do not contain sequential dates, , is/are missing.
#> non_sequential_date

# fails
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 BA.
#> non_sequential_date