# Summary.rle: Summary methods for 'rle' objects. In rle: Common Functions for Run-Length Encoded Vectors

## Description

Summarisation functions for vectors described in Summary are implemented for `rle` objects.

## Usage

 ```1 2``` ```## S3 method for class 'rle' Summary(..., na.rm) ```

## Arguments

 `...` `rle` objects or objects that can be coerced to `rle`. `na.rm` Whether the missing values should be ignored (`TRUE`) or propagated (`FALSE`).

## Details

Supported functions include all elements of the S3 Summary group. As of this writing, functions supported include (from R help) `all`, `any`, `max`, `min`, `prod`, `range`, and `sum`.

## Value

In every supported case, the call should produce the same result as what would have resulted had the call been applied to the original (uncompressed) vector. (At no point in the calculation is the uncompressed vector actually constructed, of course.) The exception is that if `values` are of class `integer`, the result will nonetheless always be upcast to `numeric` to avert overflows. This behaviour may change in the future.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```x <- rle(as.logical(rbinom(20,1,.7))) y <- rle(as.logical(rbinom(20,1,.3))) stopifnot(isTRUE(all.equal(any(x, y),any(inverse.rle(x), inverse.rle(y))))) stopifnot(isTRUE(all.equal(any(y),any(inverse.rle(y))))) stopifnot(isTRUE(all.equal(sum(inverse.rle(x),inverse.rle(y)),sum(x,y)))) stopifnot(isTRUE(all.equal(sum(inverse.rle(y)),sum(y)))) y\$values[2:3] <- NA stopifnot(isTRUE(all.equal(sum(inverse.rle(y), na.rm=TRUE),sum(y, na.rm=TRUE)))) stopifnot(isTRUE(all.equal(sum(inverse.rle(y), na.rm=FALSE),sum(y, na.rm=FALSE)))) ```

rle documentation built on Jan. 13, 2021, 6:17 p.m.