[R] Need help locating the longest series of consecutive numbers in a matrix

Staples, Angela Dawn adstaple at indiana.edu
Wed Oct 28 17:27:09 CET 2009

I need to determine the length of the longest series of consecutive numbers
(1's to be specific) and the start time of that series. For example, in the
following sample, the first column is "time" and the second column indicates
the presence of the target behavior.

I would like a function that would return "21" as the start time and "17" as
the length.

sample <- 

I would appreciate any suggestions you have.

~ Angela

More information about the R-help mailing list