rowAvgsPerColSet {MatrixGenerics} | R Documentation |
Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows).
rowAvgsPerColSet(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAvgsPerColSet(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) ## S4 method for signature 'ANY' rowAvgsPerColSet(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) colAvgsPerRowSet(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAvgsPerRowSet(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE) ## S4 method for signature 'ANY' colAvgsPerRowSet(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE)
X |
An |
W |
An optional numeric |
rows, cols |
A |
S |
An integer |
FUN |
A row-by-row (column-by-column) summary statistic function. It is
applied to to each column (row) subset of |
... |
Additional arguments passed to |
na.rm |
(logical) Argument passed to |
tFUN |
If |
The S4 methods for x
of type matrix
,
array
, or numeric
call
matrixStats::rowAvgsPerColSet
/ matrixStats::colAvgsPerRowSet
.
Returns a numeric JxN
(MxJ
) matrix.
matrixStats::rowAvgsPerColSet()
and matrixStats::colAvgsPerRowSet()
which are used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(20), nrow = 5, ncol = 4) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) S <- matrix(1:ncol(mat), ncol = 2) print(S) rowAvgsPerColSet(mat, S = S, FUN = rowMeans) rowAvgsPerColSet(mat, S = S, FUN = rowVars)