# Math.rle: Mathematical functions for 'rle' Objects In statnet/rle: Common Functions for Run-Length Encoded Vectors

## Description

Mathematical functions that work independently elementwise on vectors described in Math are implemented for `rle` objects. See Details for list of exceptions.

## Usage

 ```1 2``` ```## S3 method for class 'rle' Math(x, ...) ```

## Arguments

 `x` An `rle` object. `...` Additional arguments.

## Details

Supported functions include all elements of the S3 Math group excluding the "cumulative" ones, which are not supported at this time and will raise an error. As of this writing, functions supported include (from R help) `abs`, `sign`, `sqrt`, `floor`, `ceiling`, `trunc`, `round`, `signif`, `exp`, `log`, `expm1`, `log1p`, `cos`, `sin`, `tan`, `cospi`, `sinpi`, `tanpi`, `acos`, `asin`, `atan`, `cosh`, `sinh`, `tanh`, `acosh`, `asinh`, `atanh`, `lgamma`, `gamma`, `digamma`, and `trigamma`.

Functions `cumsum`, `cumprod`, `cummax`, and `cummin` are not supported at this time and will raise an error.

## Value

In every supported case, the call should result in an `rle` that would have resulted had the call been applied to the original (uncompressed) vector, then compressed using `rle`. (At no point in the calculation is the uncompressed vector actually constructed, of course.)

By default, the functions do not merge adjacent runs with the same value. This must be done explicitly with `compress.rle`.

## Examples

 ```1 2 3 4``` ```x <- rle(sample(runif(2), 10, c(.7,.3), replace=TRUE)) stopifnot(isTRUE(all.equal(sin(inverse.rle(x)),inverse.rle(sin(x))))) stopifnot(inherits(try(cumprod(x)), "try-error")) ```

statnet/rle documentation built on Jan. 5, 2021, 3:31 a.m.