rle-methods | R Documentation |
rle
ObjectsMiscellaneous Common Methods for rle
Objects
## S3 method for class 'rle'
c(...)
## S3 method for class 'rle'
mean(x, na.rm = FALSE, ...)
## S3 method for class 'rle'
length(x)
## S3 method for class 'rle'
is.na(x)
## S3 method for class 'rle'
str(object, ...)
... |
For |
x , object |
An |
na.rm |
Whether missing values are to be ignored ( |
The length
method returns the length of the vector
represented by the object, obtained by summing the lengths of
individual runs. This can be overridden by setting
options(rle.unclass_index = FALSE)
, which causes it to
return the length of the underlying representation (usually 2) instead.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.