[R] count repetitions

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Thu May 11 18:02:35 CEST 2006


Jean-Pierre GERBAL wrote:
> 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 ?

  rle(x)

> merci :-)

pas de prob.

Barry




More information about the R-help mailing list