[R] identify number of sequences from a vector

roger koenker rkoenker at uiuc.edu
Tue Oct 9 17:26:17 CEST 2007


this  seems to be a good candidate for a \concept{} entry
since it is it is not found by

	help.search("runs")

on R version 2.6.0 Under development (unstable) (2007-09-03 r42749).


url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    rkoenker at uiuc.edu            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820


On Oct 9, 2007, at 9:41 AM, Marc Schwartz wrote:

> O
>
> Look at ?rle
>
> Example:
>
>> Vec
>  [1] 1 1 1 0 0 1 1 1 1 1 1
>
>> rle(Vec)
> Run Length Encoding
>   lengths: int [1:3] 3 2 6
>   values : num [1:3] 1 0 1
>
>> length(rle(Vec)$lengths)
> [1] 3
>
>
> HTH,
>
> Marc Schwartz
>



More information about the R-help mailing list