drle-class: Delta Run Length Encoding

drle-classR Documentation

Delta Run Length Encoding

Description

The drle class stores delta-run-length-encoded vectors. These differ from other run-length-encoded vectors provided by other packages in that they allow for runs of values that each differ by a common difference (delta).

Usage

## Instance creation
drle(x, type = "drle", cr_threshold = 0)

is.drle(x)
## Additional methods documented below

Arguments

x

An integer or numeric vector to convert to delta run length encoding for drle(); an object to test if it is of class drle for is.drle().

type

The type of compression to use. Must be "drle", "rle", or "seq". The default ("drle") allows arbitrary deltas. Using type "rle" means that runs must consist of a single value (i.e., deltas must be 0). Using type "seq" means that deltas must be 1, -1, or 0.

cr_threshold

The compression ratio threshold to use when converting a vector to delta run length encoding. The default (0) always converts the object to drle. Values of cr_threshold < 1 correspond to compressing even when the output will be larger than the input (by a certain ratio). For values > 1, compression will only take place when the output is (approximately) at least cr_threshold times smaller.

Value

An object of class drle.

Slots

values:

The values that begin each run.

lengths:

The length of each run.

deltas:

The difference between the values of each run.

Creating Objects

drle instances can be created through drle().

Methods

Standard generic methods:

x[i]:

Get the elements of the uncompressed vector.

length(x):

Get the length of the uncompressed vector.

c(x, ...):

Combine vectors.

Author(s)

Kylie A. Bemis

See Also

rle

Examples

## Create a drle vector
x <- c(1,1,1,1,1,6,7,8,9,10,21,32,33,34,15)
y <- drle(x)

# Check that their elements are equal
x == y[]

kuwisdelu/matter documentation built on Dec. 8, 2024, 8:09 p.m.