RleArray-class {DelayedArray} | R Documentation |
The RleArray class is an array-like container where the values are stored in a run-length encoding format. RleArray objects support delayed operations and block processing.
RleArray(rle, dim, dimnames=NULL, chunksize=NULL) # constructor function
rle |
An Rle object. |
dim |
The dimensions of the object to be created, that is, an integer vector of length one or more giving the maximal indices in each dimension. |
dimnames |
Either |
chunksize |
Experimental. Don't use! |
RleArray extends DelayedArray. All the operations available on DelayedArray objects work on RleArray objects.
Rle objects in the S4Vectors package.
DelayedArray objects.
DelayedArray-utils for common operations on DelayedArray objects.
realize
for realizing a DelayedArray object in memory
or on disk.
HDF5Array objects in the HDF5Array package.
DataFrame objects in the S4Vectors package.
array objects in base R.
rle <- Rle(sample(6L, 500000, replace=TRUE), 8) a <- array(rle, dim=c(50, 20, 4000)) # array() expands the Rle object # internally with as.vector() A <- RleArray(rle, dim=c(50, 20, 4000)) # Rle object is NOT expanded A object.size(a) object.size(A) stopifnot(identical(a, as.array(A))) toto <- function(x) (5 * x[ , , 1] ^ 3 + 1L) * log(x[, , 2]) b <- toto(a) head(b) B <- toto(A) # very fast! (operations are delayed) B # still 3 dimensions (subsetting a DelayedArray object never drops # dimensions) B <- drop(B) B stopifnot(identical(b, as.array(B))) cs <- colSums(b) CS <- colSums(B) stopifnot(identical(cs, CS)) ## Coercion of a DelayedMatrix object to DataFrame produces a DataFrame ## object with Rle columns: as(B, "DataFrame")