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 <- matrix(data=c(1:40,rep(0,10),rep(1,3),rep(0,3),1,0,1,0,rep(1,17),0,0,0),40,2 ) I would appreciate any suggestions you have. Respectfully, ~ Angela ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.