Identifies contiguous periods ("bouts") where temperature is consistently above or below a user-defined threshold, allowing optional gap-tolerant detection and customizable duration calculation.
Arguments
- df
A grouped data frame with at least columns:
rfid,common_dt,variable, andvalue. Must be grouped (e.g., byrfid) prior to calling this function.- threshold
Numeric threshold to compare against temperature values.
- sampling_interval
A numeric value representing the sampling interval in minutes, or a function that takes
dfand returns a single numeric value (e.g.,estimate_sampling_interval()).- direction
Either
"below"or"above"to determine whether to identify values less than or equal to ("below") or greater than or equal to ("above") the threshold.- greedy
Logical. If
TRUE, allowsmax_gapNAs within a bout. IfFALSE, bouts are broken by any NA or threshold-violating value.- max_gap
Maximum number of consecutive
NAvalues allowed within a bout whengreedy = TRUE.- duration_mode
How to compute bout duration:
"strict": calculatesend - start"inclusive": calculatesend - start + sampling_interval
- drop_single_point_bouts
If
TRUE, removes bouts consisting of only one time point (i.e., duration = 0 in"strict"mode). Default isFALSE.- fill_undetected_groups
If
TRUE(default), ensures that all groups from the input are represented in the output, even if no bouts were found, withduration_minutes = 0.