sums {slam} | R Documentation |
Form row and column sums and means for sparse arrays (currently
simple_triplet_matrix
only).
rowSums(x, na.rm = FALSE, dims = 1, ...) colSums(x, na.rm = FALSE, dims = 1, ...) rowMeans(x, na.rm = FALSE, dims = 1, ...) colMeans(x, na.rm = FALSE, dims = 1, ...) ## S3 method for class 'simple_triplet_matrix': rowSums(x, na.rm = FALSE, dims = 1, ...) ## S3 method for class 'simple_triplet_matrix': colSums(x, na.rm = FALSE, dims = 1, ...) ## S3 method for class 'simple_triplet_matrix': rowMeans(x, na.rm = FALSE, dims = 1, ...) ## S3 method for class 'simple_triplet_matrix': colMeans(x, na.rm = FALSE, dims = 1, ...)
x |
a sparse array containing numeric, integer, or logical values. |
na.rm |
logical. Should missing values (including NaN )
be omitted from the calculations?
|
dims |
currently not used for sparse arrays. |
... |
currently not used for sparse arrays. |
Provides fast summation over the rows or columns of sparse matrices in
simple_triplet
-form.
A numeric (double) array of suitable size, or a vector if the result
is one-dimensional. The dimnames
(or names
for a vector
result) are taken from the original array.
Results are always of storage type double
to avoid (integer)
overflows.
Christian Buchta
simple_triplet_matrix
, colSums
for dense
numeric arrays.
## x <- matrix(c(1, 0, 0, 2, 1, NA), nrow = 3) x s <- as.simple_triplet_matrix(x) rowSums(s) rowSums(s, na.rm = TRUE) colSums(s) colSums(s, na.rm = TRUE)