Calculate the duration of time VALUE exceeds a threshold (above or below)
calculate_event_duration.Rd
Calculate the duration of time VALUE exceeds a threshold (above or below)
Arguments
- dat
Data frame with columns
VALUE
(numeric),TIMESTAMP
(POSIXct), and a column for each grouping variable in...
.- threshold
Threshold value that triggers start of event. Event starts when
VALUE
is greater than (less than) OR equal tothreshold
.- ...
Grouping variables. Must be name(s) of column(s) in
dat
.- less_than
Logical argument. If
TRUE
, function identifies events whenVALUE
was less than or equal tothreshold
; ifFALSE
, the function identifies events whenVALUE
was greater than or equal tothreshold
.- summary_table
Logical argument. If
FALSE
, function will return table with all events for each grouping variable. IfTRUE
, function will return summary table with maximum event duration for each grouping variable.