Skip to content

patterns in numeric vector

1 message · C Lin

#
Hello,

Can?someone?help me with this?

I am trying to find the start and end positions in a vector where?numbers less than x is surrounded by number(s) greater than x.
 For example:
 try = c(7,223,42,55,30,25,61,5,70)
 x=40

 The desired output would be:
??? start end
1???? 5????? 6
2 ??? 8?????? 8

So the?numbers I am interested in finding is: 30, 25 and the start=?5 and end =?6
Also, 5?with the start=8 and end =?8
??
Thank you in advance for your help.