NaArray-summarization: NaArray summarization methods

NaArray-summarizationR Documentation

NaArray summarization methods

Description

EXPERIMENTAL!!!

The SparseArray package provides memory-efficient summarization methods for NaArray objects. The following methods are supported at the moment: anyNA(), any(), all(), min(), max(), range(), sum(), prod(), mean(), var(), sd().

More might be added in the future.

Note that these are S4 generic functions defined in base R and in the BiocGenerics package, with default methods defined in base R. This man page documents the methods defined for NaArray objects.

Details

All these methods operate natively on the NaArray representation, for maximum efficiency.

Value

See man pages of the corresponding default methods in the base package (e.g. ?base::range, ?base::mean, etc...) for the value returned by these methods.

See Also

  • NaArray objects.

  • The man pages of the various default methods defined in the base package e.g. base::range, base::mean, base::anyNA, etc...

Examples

naa <- NaArray(dim=c(4, 5, 2))
naa[c(1:2, 8, 10, 15:17, 24:26, 28, 40)] <- (1:12)*10L
naa

anyNA(naa)

range(naa, na.rm=TRUE)

sum(naa, na.rm=TRUE)

sd(naa, na.rm=TRUE)

## Sanity checks:
a0 <- as.array(naa)
stopifnot(
  identical(anyNA(naa), anyNA(a0)),
  identical(range(naa), range(a0)),
  identical(range(naa, na.rm=TRUE), range(a0, na.rm=TRUE)),
  identical(sum(naa), sum(a0)),
  identical(sum(naa, na.rm=TRUE), sum(a0, na.rm=TRUE)),
  all.equal(sd(naa, na.rm=TRUE), sd(a0, na.rm=TRUE))
)

Bioconductor/SparseArray documentation built on Oct. 30, 2024, 12:14 p.m.