
Scan Candidate Weather Windows Relative to a Reference Time
Source:R/scan_windows.R
scan_windows.RdFor each candidate window, subsets the weather series relative to a reference time and computes summary features. The reference can be an assessment date, planting date, flowering date, inoculation date, or any other biologically meaningful timestamp.
Usage
scan_windows(
weather,
reference_time,
windows,
weather_cols,
time_col = "time",
unit = c("days", "hours"),
statistics,
sampling_interval = NULL,
max_allowed_missing_pct = NULL
)Arguments
- weather
A weather data frame.
- reference_time
Reference time used to place the candidate windows.
- windows
A data frame created by
make_windows()ordefine_windows().- weather_cols
Required character vector of existing numeric weather columns. Column names must be unique, non-missing, and non-empty. If named, every entry must have a unique, non-missing, non-empty output alias;
.conditionsis reserved. No columns are inferred. Usecharacter()explicitly for condition-only summaries.- time_col
Name of the weather timestamp column.
- unit
Time unit for relative-time windows. One of
"days"or"hours".- statistics
Required summary specification. Use a non-empty character vector to apply the same statistics to all
weather_cols, such asc("mean", "sd", "IQR"). Alternatively, use a named list keyed by every selected column's output alias (or column name when unnamed), with no unknown keys. Each entry must be a non-empty character vector or a nested named list of functions or single function names, for examplelist(temp = list(avg = "mean", spread = stats::sd)). Statistic names must be unique, non-missing, and non-empty. No summaries are inferred. The optional.conditionsentry is a named list of multivariable condition summaries such ascount_when(temp >= 18 & rh >= 90).- sampling_interval
Expected spacing between measurements, in
unit. IfNULL, uses the shortest gap between recorded timestamps within the series, or one unit if fewer than two timestamps are available. Supply the spacing when gaps may hide the actual sampling frequency.- max_allowed_missing_pct
Optional maximum missing percentage (0 to 100). If any window exceeds it, drop that predictor across windows. The
missing_pct_diagnostics are retained.NULLkeeps all predictors.