# Example 1: Valid input without group_col
# Beispiel 1: Gueltige Eingabe ohne Gruppenvariable
df <- data.frame(
datum = seq.Date(from = as.Date("2023-12-01"), to = as.Date("2025-02-28"), by = "day"),
neue_faelle = sample(0:100, 456, replace = TRUE)
)
check_input_validity(
months = c(12, 1, 2),
years = c(2024, 2025),
shift_month = "mth_to_next",
granularity = "day",
agg_fun = "sum",
df = df
)
# Example 2: group_col exists but is not a factor
# Beispiel 2: group_col ist kein Faktor: Hinweis wird ausgegeben
df$region <- sample(c("Nord", "Sued", "West"), size = nrow(df), replace = TRUE)
check_input_validity(
months = c(12, 1, 2),
years = c(2024, 2025),
shift_month = "mth_to_next",
granularity = "day",
agg_fun = "mean",
df = df,
group_col = "region"
)
# Example 3: Too many group levels triggers a message
# Beispiel 3: Zu viele Gruppenauspraegungen (>8): Warnung zur Plot-Lesbarkeit
df$gruppe <- factor(paste0("G", sample(1:12, size = nrow(df), replace = TRUE)))
check_input_validity(
months = c(12, 1, 2),
years = c(2024, 2025),
shift_month = "mth_to_next",
granularity = "week",
agg_fun = "median",
df = df,
group_col = "gruppe"
)
Run the code above in your browser using DataLab