Skip to content
Prev 361499 / 398503 Next

find longest consecutive streak in double

Hi Nick,
I think you want to get the maximum run length:

jja<-runif(92,0,16)
med_jja<-median(jja)
med_jja
[1] 7.428935
# get a logical vector of values greater than the median
jja_plus_med<-jja > med_jja
# now get the length of runs
runs_jja_plus_med<-rle(jja_plus_med)
# finally find the maximum run length
max(runs_jja_plus_med$lengths)
[1] 5

Jim
On Mon, Jun 6, 2016 at 5:51 AM, Nick Tulli <nick.tulli.95 at gmail.com> wrote: