decode_it: Calculate the _vector_ of data from its run length encoding.

View source: R/RcppExports.R

decode_itR Documentation

Calculate the vector of data from its run length encoding.

Description

Calculate the vector of data from its run length encoding.

Usage

decode_it(encodel)

Arguments

encodel

A list with two vectors: a numeric vector of encoded data and an integer vector of data counts (repeats).

Details

The function decode_it() the vector of data from its run length encoding.

The run length encoding of a vector consists of two vectors: a numeric vector of encoded data (consecutive data values) and of an integer vector of the data counts (the number of times the same value repeats in succession).

Run length encoding (RLE) is a data compression algorithm which encodes the data in two vectors: the consecutive data values and their counts. If a data value occurs several times in succession then it is recorded only once and its corresponding count is equal to the number of times it occurs. Run-length encoding is different from a contingency table.

Value

A numeric vector.

Examples

## Not run: 
# Create a vector of data
datav <- sample(5, 31, replace=TRUE)
# Calculate the run length encoding of datav
rle <- HighFreq::encode_it(datav)
# Decode the data from its run length encoding
decodev <- HighFreq::decode_it(rle)
all.equal(datav, decodev)

## End(Not run)


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.