I have a large data frame and I need a function to automate this search. Basically I want to find how many observations are between the first observation and the first two consecutive negative observations.
Example:
x <- c(2, 1, 9, 3, 4, -6, 5, 6, -7, -1)
Assuming that this is my data I want to count the number of data points between 2 and -7.
I need to do this in r.
Help is highly appreciated :D !!!