Identifies periods of low activity in a time series by analyzing peaks and troughs,
returning a logical vector marking these periods. Low activity periods are defined
as regions between consecutive troughs that contain no peaks.
Usage
classify_low_periods(peaks, troughs)
Arguments
- peaks
logical vector; TRUE indicates peak positions
- troughs
logical vector; same length as peaks, TRUE indicates trough positions
Value
logical vector; TRUE indicates periods of low activity
Details
The function performs the following steps:
Validates input lengths
Initializes all periods as potentially low activity (TRUE)
For each pair of consecutive troughs:
If no peaks exist between them, maintains TRUE for that period
If any peaks exist, marks that period as FALSE (not low activity)
Examples
peaks <- c(FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE)
troughs <- c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE)
classify_low_periods(peaks, troughs)
#> [1] TRUE TRUE TRUE TRUE FALSE FALSE TRUE