colStats | R Documentation |
These functions perform calculation of summary statistics over matrix rows and columns for each level of a grouping variable.
## S4 method for signature 'ANY'
rowStats(x, stat, ..., BPPARAM = bpparam())
## S4 method for signature 'ANY'
colStats(x, stat, ..., BPPARAM = bpparam())
## S4 method for signature 'matter_mat'
rowStats(x, stat, ..., BPPARAM = bpparam())
## S4 method for signature 'matter_mat'
colStats(x, stat, ..., BPPARAM = bpparam())
## S4 method for signature 'sparse_mat'
rowStats(x, stat, ..., BPPARAM = bpparam())
## S4 method for signature 'sparse_mat'
colStats(x, stat, ..., BPPARAM = bpparam())
.rowStats(x, stat, group = NULL,
na.rm = FALSE, simplify = TRUE, drop = TRUE,
iter.dim = 1L, BPPARAM = bpparam(), ...)
.colStats(x, stat, group = NULL,
na.rm = FALSE, simplify = TRUE, drop = TRUE,
iter.dim = 2L, BPPARAM = bpparam(), ...)
x |
A matrix on which to calculate summary statistics. |
stat |
The name of summary statistics to compute over the rows or columns of a matrix. Allowable values include: "min", "max", "prod", "sum", "mean", "var", "sd", "any", "all", and "nnzero". |
group |
A factor or vector giving the grouping. If not provided, no grouping will be used. |
na.rm |
If |
simplify |
Simplify the results from a list to a vector or array. This also drops any additional attributes (besides names). |
drop |
If only a single summary statistic is calculated, return the results as a vector (or matrix) rather than a list. |
iter.dim |
The dimension to iterate over. Must be 1 or 2, where 1 indicates rows and 2 indicates columns. |
BPPARAM |
An optional instance of |
... |
Additional arguments passed to |
The summary statistics methods are calculated over chunks of the matrix using s_colstats
and s_rowstats
. For matter
objects, the iteration is performed over the major dimension for IO efficiency.
A list for each stat
requested, where each element is either a vector (if no grouping variable is provided) or a matrix where each column corresponds to a different level of group
.
If drop=TRUE
, and only a single statistic is requested, then the result will be unlisted and returned as a vector or matrix.
Kylie A. Bemis
colSums
register(SerialParam())
set.seed(1)
x <- matrix(runif(100^2), nrow=100, ncol=100)
g <- as.factor(rep(letters[1:5], each=20))
colStats(x, "mean", group=g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.