rle2.RdCompute the lengths, values and indices of runs of equal values in a
vector. This is a modifed version of base function rle().
rle2(x) # S3 method for rle2 print(x, digits = getOption("digits"), prefix = "", ...)
| x | an atomic vector for |
|---|---|
| ... | further arguments; ignored here. |
| digits | number of significant digits for printing, see
|
| prefix | character string, prepended to each printed line. |
Missing values are regarded as unequal to the previous value, even if that is also missing.
inverse.rle() is the inverse function of rle2() and rle(),
reconstructing x from the runs.
rle() returns an object of class "rle" which is a list
with components:
an integer vector containing the length of each run.
a vector of the same length as lengths with the
corresponding values.
#> Run Length Encoding #> lengths: int [1:5] 5 4 3 2 1 #> values : int [1:5] 10 9 8 7 6## lengths [1:5] 5 4 3 2 1 ## values [1:5] 10 9 8 7 6 rle2(x)#> Run Length Encoding #> lengths: int [1:5] 5 4 3 2 1 #> values : int [1:5] 10 9 8 7 6 #> indices: int [1:5] 5 9 12 14 15## lengths: int [1:5] 5 4 3 2 1 ## values : int [1:5] 10 9 8 7 6 ## indices: int [1:5] 5 9 12 14 15