per: Decompose an atomic vector to its successive values and their...

Description Usage Arguments Value Examples

View source: R/utils_pkgtools.r

Description

The reverse of 'base::rep()' function: decompose an atomic vector to its successive values and their length.

Usage

1
per(x, idx = TRUE)

Arguments

x

The atomic vector to examine.

idx

Should the indexes (start and end) of homogeneous sequences be returned as well ?

Value

A data frame with values and lengths of the homogeneous sequences of x. The class of the column 'value' is copied from the input.

Examples

1
2
3
4
(x <- rep(LETTERS[1:10], 10:1))
(y <- per(x))
identical(rep(y$value, y$length), x)   # TRUE
inherits(y$value, class(x))            # TRUE

SESman/rbl documentation built on June 24, 2017, 8:48 a.m.