Try this: rle(y)$len[c(1, length(rle(y)$len))]
On Fri, Oct 24, 2008 at 10:34 AM, gallon li <[EMAIL PROTECTED]> wrote: > I have a list of {0,1} values, say > > y<-c(0,0,0,1,1,0,0,1,0,1,1,1,1) > > I want to compute the first few zeros and the last few ones. So the output > I > expect is 3 and 4 for this vector. Is there a fast way to match the numbers > easily? > > [[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.