i_rle {iterors}R Documentation

Run-length encoding iterator.

Description

This is an iterator equivalent of rle; it produces one output value for each run if identical values in its input, along with the lenght of the run. i_rle_inverse() performs the inverse transformstion.

Usage

i_rle(obj, cmp = identical, ...)

i_rleinv(obj, ...)

Arguments

obj

An iterable

cmp

A function to use for comparison. It should take two arguments and return TRUE or FALSE.

...

further arguments forwarded to iteror(obj, ...).

Value

An iterator returning entries of the form list(length=n, value=X).

i_rleinv recreates the original data from the output of i_rle.

Author(s)

Peter Meilstrup

See Also

i_dedupe

Examples

it <- isample(c(TRUE, FALSE), 1, replace=TRUE)
rle <- i_rle(it)
x <- take(rle, 10)
as.logical(i_rleinv(x))

[Package iterors version 1.0 Index]