ConstantArray-class: A DelayedArray subclass that contains a constant value

ConstantArrayR Documentation

A DelayedArray subclass that contains a constant value

Description

A DelayedArray subclass to efficiently mimic an array containing a constant value, without actually creating said array in memory.

Usage

## Constructor function:
ConstantArray(dim, value=NA)

Arguments

dim

The dimensions (specified as an integer vector) of the ConstantArray object to create.

value

Vector (atomic or list) of length 1, containing the value to fill the matrix.

Details

This class allows us to efficiently create arrays containing a single value. For example, we can create matrices full of NA values, to serve as placeholders for missing assays when combining SummarizedExperiment objects.

Value

A ConstantArray (or ConstantMatrix) object. (Note that ConstantMatrix extends ConstantArray.)

Author(s)

Aaron Lun

See Also

  • DelayedArray objects.

  • DelayedArray-utils for common operations on DelayedArray objects.

  • RleArray objects for representing in-memory Run Length Encoded array-like datasets.

Examples

## This would ordinarily take up 8 TB of memory:
CM <- ConstantArray(c(1e6, 1e6), value=NA_real_)
CM

CM2 <-ConstantArray(c(4, 1e6), value=55)
rbind(CM, CM2)

Bioconductor/DelayedArray documentation built on Nov. 18, 2024, 3:06 a.m.