Great :)


________________________________
From: Dimitris Rizopoulos <d.rizopou...@erasmusmc.nl>

Cc: "R-help@r-project.org" <R-help@r-project.org>
Sent: Thursday, October 6, 2011 9:22 AM
Subject: Re: [R] Concecutive zeros and ones

Check function rle().


I hope it helps.

Best,
Dimitris



On 10/6/2011 9:18 AM, Alaios wrote:
> Dear all,
> I have  a data series (might be vector or matrix) which is composed only from 
> zeros and ones like the following example
>
> 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 0
>
> I want to be able to return back the length of concecutive zeros and the 
> length of concecutive ones.
>
> For that I want to have something like that returned:
>
>
> zeros= [3 1 2 3];
> ones=[2 1 4];
>
> How I can do that simply in R?
>
> I would like to thank you in advance for your help
>
>
> B.R
> Alex
>
>     [[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.

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/
        [[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.

Reply via email to