colsweep | R Documentation |
Apply the equivalent of sweep
to either columns or rows of a matrix, using a grouping variable.
## S4 method for signature 'ANY'
colsweep(x, STATS, FUN = "-", group = NULL, ...)
## S4 method for signature 'matter_mat'
colsweep(x, STATS, FUN = "-", group = NULL, ...)
## S4 method for signature 'sparse_mat'
colsweep(x, STATS, FUN = "-", group = NULL, ...)
## S4 method for signature 'ANY'
rowsweep(x, STATS, FUN = "-", group = NULL, ...)
## S4 method for signature 'matter_mat'
rowsweep(x, STATS, FUN = "-", group = NULL, ...)
## S4 method for signature 'sparse_mat'
rowsweep(x, STATS, FUN = "-", group = NULL, ...)
x |
A matrix-like object. |
STATS |
The summary statistic to be swept out, with length equal to the number of columns of 'x' (for |
FUN |
The function to be used to carry out the sweep. |
group |
A vector or factor giving the groupings with length equal to the number of rows of 'x' (for |
... |
Ignored. |
See sweep
for details.
A matrix-like object (usually of the same class as x
) with the statistics swept out.
Kylie A. Bemis
sweep
set.seed(1)
x <- matrix(1:100, nrow=10, ncol=10)
colsweep(x, colStats(x, "mean"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.