Apply Threshold to Identify Events
apply_threshold.Rd
Identifies and extracts events in a time series based on threshold criteria, with options for event selection and characterization.
Usage
apply_threshold(
X,
lim,
where = "<=",
what = "X",
select = "all",
Date = NULL,
period = NULL
)
Arguments
- X
Numeric vector of values to analyze (typically discharge or other hydro-meteorological variable)
- lim
Numeric threshold value or vector of same length as X
- where
String specifying threshold condition:
"<", "<=", "==", ">=", ">" for standard comparisons
- what
String specifying return type:
"X": Values meeting condition
"length": Duration of events (time steps)
"first"/"last": First/last index of events
Any function name (e.g., "which.max"): Applied to event values
- select
String or numeric specifying event selection:
"all": All events (default)
"longest"/"shortest": Longest/shortest event
Numeric value: Event containing this value
- Date
Optional date vector for period filtering
- period
Optional vector of 2 dates (start/end) for period filtering
Value
Depends on what
parameter:
Numeric vector of values ("X")
Integer duration ("length")
Single index ("first"/"last")
Function application result
NA if no events found
Details
Handles multiple threshold scenarios:
For vector
lim
, uses most frequent value viarle()
For period filtering, subsets data before analysis
For event selection, identifies contiguous periods