| sumGroups | R Documentation |
For each unique value of the grouping vector y, sums the
corresponding rows (or columns) of X. Used internally by
wilcoxauc() and collapse_counts(), but exposed as a fast
group-wise reduction primitive that works on both dense matrices
and dgCMatrix sparse inputs.
sumGroups(X, y, MARGIN = 2)
## S3 method for class 'dgCMatrix'
sumGroups(X, y, MARGIN = 2)
## S3 method for class 'matrix'
sumGroups(X, y, MARGIN = 2)
X |
Numeric matrix or |
y |
Group label vector. Coerced to integer factor codes. |
MARGIN |
Whether observations are along rows or columns of |
Numeric matrix of shape n_groups x n_features. Row order
matches the integer order of factor(y).
nnzeroGroups(), wilcoxauc()
set.seed(42)
exprs <- matrix(rpois(25 * 150, lambda = 2), nrow = 25,
dimnames = list(paste0("G", 1:25), NULL))
y <- rep(c("A", "B", "C"), each = 50)
sumGroups_res <- sumGroups(exprs, y, 1)
sumGroups_res <- sumGroups(t(exprs), y, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.