Learn R Programming

rle (version 0.9.2)

rle-methods: Miscellaneous Common Methods for rle Objects

Description

Miscellaneous Common Methods for rle Objects

Usage

# S3 method for rle
c(...)

# S3 method for rle mean(x, na.rm = FALSE, ...)

# S3 method for rle length(x)

# S3 method for rle is.na(x)

# S3 method for rle str(object, ...)

Arguments

...

For c, objects to be concatenated. The first object must be of class rle.

x, object

An rle object.

na.rm

Whether missing values are to be ignored (TRUE) or propagated (FALSE).

Examples

Run this code
# NOT RUN {
x <- rle(as.logical(rbinom(10,1,.7)))
y <- rle(as.logical(rbinom(10,1,.3)))

stopifnot(isTRUE(all.equal(c(inverse.rle(x),inverse.rle(y)),inverse.rle(c(x,y)))))


stopifnot(isTRUE(all.equal(mean(inverse.rle(x)),mean(x))))
stopifnot(isTRUE(all.equal(mean(inverse.rle(y)),mean(y))))


stopifnot(isTRUE(all.equal(length(inverse.rle(x)),length(x))))
stopifnot(isTRUE(all.equal(length(inverse.rle(y)),length(y))))

x$values[1] <- NA
y$values[1] <- NA
stopifnot(isTRUE(all.equal(is.na(inverse.rle(x)),inverse.rle(is.na(x)))))
stopifnot(isTRUE(all.equal(is.na(inverse.rle(y)),inverse.rle(is.na(y)))))


str(x)

# }

Run the code above in your browser using DataLab