Suppose X is a long vector of integers (typically about 30000 elements). Is there an efficient way to detect whether there are at least N consecutive zeros in X, and if yes, where does this occur?
for example, suppose X is: 1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 0 1 2 0 0 0 2 2 2 2 2 ... and N is 10. I would like a foo(X, 10) to return something like c(6,19) (start and end positions in X of at least 10 consecutive zeros). I can think of a number of slow and probably inefficient ways of doing it (nested loops..), but perhaps someone has a better idea.. Thanks in advance, Kenn [[alternative HTML version deleted]] ______________________________________________ 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.