[R] Calculating length of consecutive sequences within a vector
R. Michael Weylandt
michael.weylandt at gmail.com
Thu Mar 8 17:29:40 CET 2012
rle should get you started.
On Thu, Mar 8, 2012 at 9:35 AM, Jorge Molinos <JGARCIAM at tcd.ie> wrote:
> Hi all,
> I have a nx1 logical array of zeros and ones and I want to calculate the individual lengths of all 1-consecutive sequences contained in it. Is there an easy quick way to do this in R? So, if I have a vector such as
> I would like to get (1) 3, (2) 2, (3) 1, (4) 7
> Any help would be appreciated! thanks!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help