I have a daily time series of wind speeds and I would like R to return the average and maximum length of consecutive days beneath a certain threshold.
Example (Threshold = 2 m/s):
df >
date wind_speed
1970-01-01 1
1970-01-02 1
1970-01-03 3
1970-01-04 1
1970-01-05 1
1970-01-06 1
1970-01-07 3
1970-01-08 1
So. In this example the maximum length of consecutive days under 2 m/s would be "3" and the average lenght would be "2". Is there a way to do this in R for large data sets?
Thanks in advance