encode_it: Calculate the run length encoding of a single-column _time...

View source: R/RcppExports.R

encode_itR Documentation

Calculate the run length encoding of a single-column time series, matrix, or a vector.

Description

Calculate the run length encoding of a single-column time series, matrix, or a vector.

Usage

encode_it(tseries)

Arguments

tseries

A single-column time series, matrix, or a vector.

Details

The function encode_it() calculates the run length encoding of a single-column time series, matrix, or a vector.

The run length encoding of a vector consists of two vectors: a 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 list with two vectors: a vector of encoded data and an integer vector of data counts (repeats).

Examples

## Not run: 
# Create a vector of data
datav <- sample(5, 31, replace=TRUE)
# Calculate the run length encoding of datav
HighFreq::encode_it(datav)

## End(Not run)


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