seqle: Extends 'rle' to find and encode linear sequences.

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

The function rle, or "run-length encoder," is a simple compression scheme which identifies sequences of repeating values in a vector. seqle extends this scheme by allowing the user to specify a sequence of values with a common "slope," or delta value, between adjacent elements. seqle with an increment of zero is the same as rle.

Usage

1
seqle(x, incr = 1L, prec = .Machine$double.eps^0.5)

Arguments

x

The input vector of values.

incr

The desired increment between elements which specifies the sequences to search for. Note that this can be either integer or float. For floating-point sequences, see the prec argument for determining what level of precision is used to determine whether elements continue a sequence or not.

prec

Defines the required precision to which elements are compared when determining whether they are part of a sequence. Note that for integer inputs, this value is more or less meaningless.

Details

Note: the returned value is assigned the class "rle". So far as I can tell, this class has only a print method, i.e. defining what is returned to the console when the user types the name of the returned object.

Value

lengths

a vector of the lengths (1 or greater) of all sequences found.

values

a vector of the initial value for each sequence. For example, if incr ==1 a values of 5 associated with a lengths of 3 represents the sequence 5,6,7.

Note

The bulk of the code is taken directly from base::rle . Thanks to "flodel", http://www.linkedin.com/in/florentdelmotte , on StackOverflow for suggesting code to handle floating-point increments.

Author(s)

Carl Witthoft, carl@witthoft.com

See Also

rle inverse.seqle

Examples

1
2
3
4
x<- c(2,2,2,3:8,8,8,4,4,4,5,5.5,6)
seqle(x,incr=0)
seqle(x,incr=1)
seqle(x,incr=1.5)


Search within the cgwtools package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.