I have a numeric vector and I want to extract runs of decreasing values. In addition, the first value in each sequence should be >= 40
, and the last value should be <= 20
.
For example:
Mydata = c(1, 5, 0, 10, 40, 30, 25, 20, 7, 34, 23, 55, 70, 42, 38, 22, 44, 33, 11, 17, 25)
The resulting sequences are: c(40, 30, 25, 20, 7)
and c(44, 33, 11)
.