I use R and I have a long numeric vector. I would like to look for all the maximal continuous subranges in this vector, where all values are lower then some threshold.
For example, if the given vector is
5 5 6 6 7 5 4 4 4 3 2 1 1 1 2 3 4 5 6 7 6 5 4 3 2 2 3 4 4
and my threshold is 4 (i.e., =<3
), then the values that meet this condition are marked with x:
0 0 0 0 0 0 0 0 0 x x x x x x x 0 0 0 0 0 0 0 x x x x 0 0
I would also like to return something like (10,16), (24,27)
. How do I do that?