Calculate the duration of time VALUE exceeds a threshold (above or below)
calculate_event_duration.RdCalculate 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
VALUEis 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 whenVALUEwas less than or equal tothreshold; ifFALSE, the function identifies events whenVALUEwas 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.