Detect sequence of events (aka. waves) in a ordered vector considering its normal values.
Arguments
- .x
A data.frame object.
- normals_df
A data.frame object with normal values, computed with
summarise_normal().- threshold
numeric. A positive of negative threshold value to be added to the normal mean value. Use value zero to consider only the normal value.
- threshold_cond
string. A threshold condition. Use
gtefor "greather than or equal" orltefor less than or equal.- size
numeric. Minimum size of the sequence.
- var_name
string. Variable name with the outputs result.
Details
This is a helper function to detect sequence of events in a ordered vector considering historical normal values.
An event is considered as a sequence of values of a certain size (size argument) that are greather and less than (threshold_cond argument) an historical normal (normal argument) plus an threshold (threshold value).
The function will fill the variable var_name with TRUE if the record belongs to an event.