sparseMatrix utilities
Some utilities to operate natively on sparseMatrix objects (e.g. dgCMatrix and lgCMatrix objects) from the Matrix package. Mostly for internal use by the DelayedArray package.
## rowsum() and colsum() S4 generics: #rowsum(x, group, reorder=TRUE, ...) #colsum(x, group, reorder=TRUE, ...) ## Default methods: ## S4 method for signature 'ANY' rowsum(x, group, reorder=TRUE, ...) ## S4 method for signature 'ANY' colsum(x, group, reorder=TRUE, ...) ## rowsum() method for dgCMatrix objects: ## S4 method for signature 'dgCMatrix' rowsum(x, group, reorder=TRUE, ...)
x |
A numeric matrix-like object. |
group, reorder, ... |
See |
See ?base::rowsum
for the value returned
by the default rowsum
method.
The default colsum
method returns
t(rowsum(t(x), group, reorder=reorder, ...))
.
DelayedMatrix-utils in this package for the rowsum
and colsum
methods defined for DelayedMatrix objects.
base::rowsum
in the base package for
the default rowsum
method.
dgCMatrix objects in the Matrix package.
m0 <- rsparsematrix(1e5, 800, density=0.15) # sparse representation m <- as.matrix(m0) # dense representation group <- sample(20, nrow(m), replace=TRUE) ## 'rowsum(m0)' is about 4x faster than 'rowsum(m)': rs0 <- rowsum(m0, group) rs <- rowsum(m, group) stopifnot(identical(rs0, rs))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.