SparseArray-summarization | R Documentation |
The SparseArray package provides memory-efficient summarization
methods for SparseArray 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 SparseArray objects.
All these methods operate natively on the COO_SparseArray or SVT_SparseArray representation, for maximum efficiency.
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.
SparseArray objects.
The man pages of the various default methods defined in
the base package e.g. base::range
,
base::mean
, base::anyNA
,
etc...
m0 <- matrix(0L, nrow=6, ncol=4)
m0[c(1:2, 8, 10, 15:17, 24)] <- (1:8)*10L
m0[5, 2] <- NA
svt0 <- as(m0, "SVT_SparseMatrix")
svt0
anyNA(svt0)
range(svt0)
range(svt0, na.rm=TRUE)
sum(svt0, na.rm=TRUE)
sd(svt0, na.rm=TRUE)
## Sanity checks:
stopifnot(
identical(anyNA(svt0), anyNA(m0)),
identical(range(svt0), range(m0)),
identical(range(svt0, na.rm=TRUE), range(m0, na.rm=TRUE)),
identical(sum(svt0), sum(m0)),
identical(sum(svt0, na.rm=TRUE), sum(m0, na.rm=TRUE)),
all.equal(sd(svt0, na.rm=TRUE), sd(m0, na.rm=TRUE))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.