Re: [R] count repetitions

From: Francisco J. Zagmutt <gerifalte28_at_hotmail.com>
Date: Fri 12 May 2006 - 03:33:31 EST


See ?rle i.e.:

x=c(0,0,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,0,0) rle(x)
Run Length Encoding
  lengths: int [1:7] 2 3 1 3 1 4 5
  values : num [1:7] 0 1 0 1 0 1 0

I hope this helps

Francisco

>From: Jean-Pierre GERBAL <jeanpierre.gerbal@free.fr>
>To: R-help@stat.math.ethz.ch
>Subject: [R] count repetitions
>Date: Thu, 11 May 2006 17:42:55 +0200
>
>bonjour,
>
>i have a serie : x<-sample(c(0,1),50,T)
>and i want to count the length of each repetition of 0 and of 1
>(0011101110111100000 give 2313145)...
>who have an idea ?
>
>merci :-)
>
>jean-pierre
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
>http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 12 03:38:39 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 12 May 2006 - 04:10:09 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.