rle
Run Length Encoding and Decoding

Description

Computes the length and the value of runs of the same value in a vector.

Usage

rle(x)
print.rle(x, digits = getOption("digits"), prefix = "", ...) 
inverse.rle(x, ...) 

Arguments

x for rle, a vector object. For print.rle and inverse.rle, an rle object.
digits the number of digits displayed for a numeric values component.
prefix the prefix for each line.
... reserved for future use. Ignored in this version.
Value
rle()returns an rle object, which is a list containing:
  • lengths: a vector containing the length of each run.
  • values: a vector the same length as lengths, with the values of each run.
print.rle()(a print S3 method for rle object.) Prints the object's information: lengths and values.
inverse.rle()returns the rle object of a vector containing the values that replicates a certain number of runs.
See Also
sort.
Examples
x <- c(16,16,16,16,8,8,8,4,4,2,32,32,32,32,32) 
rle(x) 
identical(x, inverse.rle(rle(x)))

z <- runif(10) print(rle(z), digits = 3, prefix = "###")

Package base version 6.0.0-69
Package Index