rle(x)
inverse.rle(x, ...)
"print"(x, digits = getOption("digits"), prefix = "", ...)
rle()
;
an object of class "rle"
for inverse.rle()
.print.default
.rle()
returns an object of class "rle"
which is a list
with components:
lengths
with the
corresponding values.inverse.rle()
returns an atomic vector.
is.vector
.Missing values are regarded as unequal to the previous value, even if that is also missing.
inverse.rle()
is the inverse function of rle()
,
reconstructing x
from the runs.
x <- rev(rep(6:10, 1:5))
rle(x)
## lengths [1:5] 5 4 3 2 1
## values [1:5] 10 9 8 7 6
z <- c(TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE)
rle(z)
rle(as.character(z))
print(rle(z), prefix = "..| ")
N <- integer(0)
stopifnot(x == inverse.rle(rle(x)),
identical(N, inverse.rle(rle(N))),
z == inverse.rle(rle(z)))
Run the code above in your browser using DataLab