Learn R Programming

trendtestR (version 1.0.1)

check_continuity_by_window: Check Time Series Continuity within Defined Window / Pruefung der Zeitreihen-Kontinuitaet

Description

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.

Usage

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
)

Value

A list with the following elements:

continuous

Logical. Whether the time series is complete

gaps

Data frame of missing expected dates

datum

Vector of available dates within the window

range

Start and end of expected time window

Arguments

date_vec

A vector of dates. / Ein Datumsvektor

years

Numeric vector indicating year range (e.g., c(2021, 2022)). / Jahr(e)

months

Numeric vector of months (1:12). / Monate (1:12)

window_unit

Time unit for continuity check: "day", "week", or "month". / Zeiteinheit fuer Pruefung

step

Step size for the sequence. Default is 1. / Schrittweite

use_isoweek

Logical. If TRUE, weeks start on Monday. / ISO-Woche (Montag)?

start_date

Optional. Override default start date (must be in "YYYY-MM-DD" format). / Optionales Startdatum

allow_leading_gap

Logical. If TRUE, allows first date to be missing but considers rest as continuous. / Erlaubt Anfangsluecke?

Details

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.

Examples

Run this code
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