[R] Determine longest run of number
Mark Del Cerro
Mark.DelCerro at powerint.com
Fri Nov 2 23:05:43 CET 2012
Hi Michael,
Thanks for the response -- that's exactly what I was looking for.
Thanks,
Mark
-----Original Message-----
From: R. Michael Weylandt [mailto:michael.weylandt at gmail.com]
Sent: Friday, November 02, 2012 3:02 PM
To: Mark Del Cerro
Cc: r-help at r-project.org
Subject: Re: [R] Determine longest run of number
I believe you're looking for the rle() function.
Cheers,
Michael
On Fri, Nov 2, 2012 at 9:20 PM, Mark Del Cerro
<Mark.DelCerro at powerint.com> wrote:
> Does anybody know a way to determine the longest run of a number in a
> vector of numbers?
> For example if I have the following numbers: 0 0 1 1 1 1 0 1 1 0 0 0 1
> 1; how can I determine that the longest run of 1's = 4 and longest run
> of 0's = 3?
>
> Thanks,
> Mark
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list