Learn R Programming

bit (version 4.5.0)

rlepack: Hybrid Index, rle-pack utilities

Description

Basic utilities for rle packing and unpacking and apropriate methods for rev and unique.

Usage

rlepack(x, ...)

# S3 method for integer rlepack(x, pack = TRUE, ...)

rleunpack(x)

# S3 method for rlepack rleunpack(x)

# S3 method for rlepack rev(x)

# S3 method for rlepack unique(x, incomparables = FALSE, ...)

# S3 method for rlepack anyDuplicated(x, incomparables = FALSE, ...)

Value

A list with components

first

the first element of the packed sequence

dat

either an object of class rle or the complete input vector x if rle-packing is not efficient

last

the last element of the packed sequence

Arguments

x

in 'rlepack' an integer vector, in the other functions an object of class 'rlepack'

...

just to keep R CMD CHECK quiet (not used)

pack

FALSE to suppress packing

incomparables

just to keep R CMD CHECK quiet (not used)

Author

Jens Oehlschlägel

See Also

hi, intrle, rle, rev, unique

Examples

Run this code

  x <- rlepack(rep(0L, 10))
# \dontshow{
 for (x in list(10:1, 1:10, c(10:1,1:10), c(1:10,10:1), sample(100), sample(100, 100, TRUE), sample(10, 100, TRUE))){
   stopifnot(identical(rleunpack(rlepack(x)), x))
   stopifnot(identical(rleunpack(unique(rlepack(x))), unique(x)))
   stopifnot(identical(anyDuplicated(rlepack(x)), anyDuplicated(x)))
 }
# }

Run the code above in your browser using DataLab