This function checks whether a date vector contains all expected time points within a specified window. Users can define the time unit (day, week, or month), granularity step, and whether ISO week starts (Monday) should be used. Returns a list indicating whether the data are continuous and reports any missing dates.
check_continuity_by_window(
date_vec,
years,
months,
window_unit = c("week", "day", "month"),
step = 1,
use_isoweek = FALSE,
start_date = NULL,
allow_leading_gap = FALSE
)A list with the following elements:
Logical. Whether the time series is complete
Data frame of missing expected dates
Vector of available dates within the window
Start and end of expected time window
A vector of dates. / Ein Datumsvektor
Numeric vector indicating year range (e.g., c(2021, 2022)). / Jahr(e)
Numeric vector of months (1:12). / Monate (1:12)
Time unit for continuity check: "day", "week", or "month". / Zeiteinheit fuer Pruefung
Step size for the sequence. Default is 1. / Schrittweite
Logical. If TRUE, weeks start on Monday. / ISO-Woche (Montag)?
Optional. Override default start date (must be in "YYYY-MM-DD" format). / Optionales Startdatum
Logical. If TRUE, allows first date to be missing but considers rest as continuous. / Erlaubt Anfangsluecke?
Diese Funktion prueft, ob ein Datumsvektor alle erwarteten Zeitpunkte innerhalb eines definierten Fensters enthaelt. Die Zeitgranularitaet (Tag/Woche/Monat), Schrittweite und ISO-Wochenstart (Montag) koennen angepasst werden. Gibt zurueck, ob die Zeitreihe vollstaendig ist, und listet fehlende Zeitpunkte auf.
vec <- seq(as.Date("2021-01-01"), as.Date("2021-03-31"), by = "day")
check_continuity_by_window(vec, years = 2021, months = 1:3, window_unit = "day")
Run the code above in your browser using DataLab