This function will count the occurrence of sequential events that meets some conditions.
Arguments
- x
numeric vector.
- a_op, b_op
character. Operator,
gte
= greater than or equal,lte
= less than or equal,gt
= greater than,lt
= less than,e
= equal.- a
integer. Length of period threshold.
- b
integer. Value threshold.
- isolated
logical. Consider only isolated events, i.e. surrounded by zeros. On this case,
a
anda_op
are not considered.
Details
Example: In a vector, how many sequences have at least 3 consecutive observations (a_op = "gte", a = 3
) with values equal or greater than 5 (b_op = "gte", b = 5
)?
Examples
# How many sequences have at least 3 consecutive observations with value equal or greater than 5?
trle_cond(x = c(8,15,20,0,0,0,0,5,9,12), a_op = "gte", a = 3, b_op = "gte", b = 5)
#> [1] 2