rle(x)
x
| a vector. |
lengths
| a vector containing the length of each run. |
values
|
a vector of the same length as lengths with the
corresponding values.
|
x <- rev(rep(6:10, 1:5)) rle(x) ## $lengths ## [1] 5 4 3 2 1 ## $values ## [1] 10 9 8 7 6