Title: | S4 Generic Summary Statistic Functions that Operate on Matrix-Like Objects |
---|---|
Description: | S4 generic functions modeled after the 'matrixStats' API for alternative matrix implementations. Packages with alternative matrix implementation can depend on this package and implement the generic functions that are defined here for a useful set of row and column summary statistics. Other package developers can import this package and handle a different matrix implementations without worrying about incompatibilities. |
Authors: | Constantin Ahlmann-Eltze [aut] , Peter Hickey [aut, cre] , Hervé Pagès [aut] |
Maintainer: | Peter Hickey <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.19.0 |
Built: | 2024-12-06 05:57:03 UTC |
Source: | https://github.com/bioc/MatrixGenerics |
The MatrixGenerics package defines S4 generic summary statistic functions that operate on matrix-Like objects.
Check if all elements in a row (column) of a matrix-like object are equal to a value.
rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE)
rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
value |
The value to search for. |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowAlls
/
matrixStats::colAlls
.
Returns a logical
vector
of length N (K).
matrixStats::rowAlls()
and
matrixStats::colAlls()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
.
base::all()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAlls(mat) colAlls(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAlls(mat) colAlls(mat)
Check if any elements in a row (column) of a matrix-like object is missing.
rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowAnyNAs
/
matrixStats::colAnyNAs
.
Returns a logical
vector
of length N (K).
matrixStats::rowAnyNAs()
and
matrixStats::colAnyNAs()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAnyNAs(mat) colAnyNAs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAnyNAs(mat) colAnyNAs(mat)
Check if any elements in a row (column) of a matrix-like object is equal to a value.
rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE)
rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
value |
The value to search for. |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowAnys
/
matrixStats::colAnys
.
Returns a logical
vector
of length N (K).
matrixStats::rowAnys()
and
matrixStats::colAnys()
which are
used when the input is a matrix
or numeric
vector.
For checks if all elements are equal to a value, see
rowAlls()
.
base::any()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAnys(mat) colAnys(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAnys(mat) colAnys(mat)
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)
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
, table
, 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)
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)
Extract one cell from each row (column) of a matrix-like object.
rowCollapse(x, idxs, rows = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCollapse(x, idxs, rows = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCollapse(x, idxs, rows = NULL, ..., useNames = TRUE) colCollapse(x, idxs, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCollapse(x, idxs, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCollapse(x, idxs, cols = NULL, ..., useNames = TRUE)
rowCollapse(x, idxs, rows = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCollapse(x, idxs, rows = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCollapse(x, idxs, rows = NULL, ..., useNames = TRUE) colCollapse(x, idxs, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCollapse(x, idxs, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCollapse(x, idxs, cols = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
idxs |
An index |
rows , cols
|
A |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCollapse
/
matrixStats::colCollapse
.
Returns a numeric
vector
of length N (K).
matrixStats::rowCollapse()
and matrixStats::colCollapse()
which are used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCollapse(mat, idxs = 2) rowCollapse(mat, idxs = c(1,1,2,3,2)) colCollapse (mat, idxs = 4)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCollapse(mat, idxs = 2) rowCollapse(mat, idxs = c(1,1,2,3,2)) colCollapse (mat, idxs = 4)
Count how often an element in a row (column) of a matrix-like object is equal to a value.
rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE)
rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
value |
The value to search for. |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCounts
/
matrixStats::colCounts
.
Returns a integer
vector
of length N (K).
matrixStats::rowCounts()
and
matrixStats::colCounts()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
. To check if all elements are equal, see
rowAlls()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCounts(mat) colCounts(mat) rowCounts(mat, value = 0) colCounts(mat, value = Inf, na.rm = TRUE)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCounts(mat) colCounts(mat) rowCounts(mat, value = 0) colCounts(mat, value = Inf, na.rm = TRUE)
Calculates the cumulative maxima for each row (column) of a matrix-like object.
rowCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCummaxs(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCummaxs(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
rowCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCummaxs(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCummaxs(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCummaxs
/
matrixStats::colCummaxs
.
Returns a numeric
matrix
with the same
dimensions as x
.
matrixStats::rowCummaxs()
and
matrixStats::colCummaxs()
which are
used when the input is a matrix
or numeric
vector.
For single maximum estimates, see rowMaxs()
.
base::cummax()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCummaxs(mat) colCummaxs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCummaxs(mat) colCummaxs(mat)
Calculates the cumulative minima for each row (column) of a matrix-like object.
rowCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCummins(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCummins(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
rowCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCummins(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCummins(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCummins
/
matrixStats::colCummins
.
Returns a numeric
matrix
with the same
dimensions as x
.
matrixStats::rowCummins()
and
matrixStats::colCummins()
which are
used when the input is a matrix
or numeric
vector.
For single minimum estimates, see rowMins()
.
base::cummin()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCummins(mat) colCummins(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCummins(mat) colCummins(mat)
Calculates the cumulative product for each row (column) of a matrix-like object.
rowCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCumprods(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCumprods(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
rowCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCumprods(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCumprods(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCumprods
/
matrixStats::colCumprods
.
Returns a numeric
matrix
with the same
dimensions as x
.
matrixStats::rowCumprods()
and
matrixStats::colCumprods()
which
are used when the input is a matrix
or numeric
vector.
base::cumprod()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCumprods(mat) colCumprods(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCumprods(mat) colCumprods(mat)
Calculates the cumulative sum for each row (column) of a matrix-like object.
rowCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCumsums(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCumsums(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
rowCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowCumsums(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colCumsums(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCumsums
/
matrixStats::colCumsums
.
Returns a numeric
matrix
with the same
dimensions as x
.
matrixStats::rowCumsums()
and
matrixStats::colCumsums()
which are
used when the input is a matrix
or numeric
vector.
base::cumsum()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCumsums(mat) colCumsums(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCumsums(mat) colCumsums(mat)
Calculates the difference between each element of a row (column) of a matrix-like object.
rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE)
rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
lag |
An integer specifying the lag. |
differences |
An integer specifying the order of difference. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowDiffs
/
matrixStats::colDiffs
.
Returns a numeric
matrix
with one column
(row) less than x: or
.
matrixStats::rowDiffs()
and
matrixStats::colDiffs()
which are used
when the input is a matrix
or numeric
vector.
base::diff()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowDiffs(mat) colDiffs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowDiffs(mat) colDiffs(mat)
Calculates the interquartile range of the difference between each element of a row (column) of a matrix-like object.
rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
diff |
An integer specifying the order of difference. |
trim |
A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowIQRDiffs
/
matrixStats::colIQRDiffs
.
Returns a numeric
vector
of length N (K).
matrixStats::rowIQRDiffs()
and
matrixStats::colIQRDiffs()
which
are used when the input is a matrix
or numeric
vector.
For the direct interquartile range see also rowIQRs.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowIQRDiffs(mat) colIQRDiffs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowIQRDiffs(mat) colIQRDiffs(mat)
Calculates the interquartile range for each row (column) of a matrix-like object.
rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowIQRs
/
matrixStats::colIQRs
.
Returns a numeric
vector
of length N (K).
matrixStats::rowIQRs()
and
matrixStats::colIQRs()
which are used
when the input is a matrix
or numeric
vector.
For a non-robust analog, see rowSds()
. For a more
robust version see rowMads()
stats::IQR()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowIQRs(mat) colIQRs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowIQRs(mat) colIQRs(mat)
Accurately calculates the logarithm of the sum of exponentials for each row (column) of a matrix-like object.
rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE) ## S4 method for signature 'ANY' colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE) ## S4 method for signature 'ANY' colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
lx |
An NxK matrix-like object. Typically |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowLogSumExps
/
matrixStats::colLogSumExps
.
Returns a numeric
vector
of length N (K).
matrixStats::rowLogSumExps()
and
matrixStats::colLogSumExps()
which are used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowLogSumExps(mat) colLogSumExps(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowLogSumExps(mat) colLogSumExps(mat)
Calculates the mean absolute deviation of the difference between each element of a row (column) of a matrix-like object.
rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
diff |
An integer specifying the order of difference. |
trim |
A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMadDiffs
/
matrixStats::colMadDiffs
.
Returns a numeric
vector
of length N (K).
matrixStats::rowMadDiffs()
and
matrixStats::colMadDiffs()
which
are used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMadDiffs(mat) colMadDiffs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMadDiffs(mat) colMadDiffs(mat)
Calculates the median absolute deviation for each row (column) of a matrix-like object.
rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE)
rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
center |
(optional) the center, defaults to the row means |
constant |
A scale factor. See |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMads
/
matrixStats::colMads
.
Returns a numeric
vector
of length N (K).
matrixStats::rowMads()
and
matrixStats::colMads()
which are used
when the input is a matrix
or numeric
vector.
For non-robust standard deviation estimates, see
rowSds()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMads(mat) colMads(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMads(mat) colMads(mat)
Calculates the maximum for each row (column) of a matrix-like object.
rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMaxs
/
matrixStats::colMaxs
.
Returns a numeric
vector
of length N (K).
matrixStats::rowMaxs()
and
matrixStats::colMaxs()
which are used
when the input is a matrix
or numeric
vector.
For min estimates, see rowMins()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMaxs(mat) colMaxs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMaxs(mat) colMaxs(mat)
Calculates the mean for each row (column) of a matrix-like object.
rowMeans(x, na.rm = FALSE, dims = 1, ...) colMeans(x, na.rm = FALSE, dims = 1, ...)
rowMeans(x, na.rm = FALSE, dims = 1, ...) colMeans(x, na.rm = FALSE, dims = 1, ...)
x |
An NxK matrix-like object, a numeric data frame, or an array-like object of two or more dimensions. |
na.rm |
If |
dims |
A single integer indicating which dimensions are regarded
as rows or columns to mean over. For |
... |
Additional arguments passed to specific methods. |
This man page documents the rowMeans
and colMeans
S4 generic functions defined in the MatrixGenerics package.
See ?base::colMeans
for the default methods (defined
in the base package).
Returns a numeric
vector
of length N (K).
base::colMeans
for the default
rowMeans
and colMeans
methods.
Matrix::colMeans
in the Matrix package
for rowMeans
and colMeans
methods defined for
CsparseMatrix derivatives (e.g. dgCMatrix objects).
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMeans(mat) colMeans(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMeans(mat) colMeans(mat)
Calculates the mean for each row (column) of a matrix-like object.
rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMeans2
/
matrixStats::colMeans2
.
Returns a numeric
vector
of length N (K).
matrixStats::rowMeans2()
and
matrixStats::colMeans2()
which are
used when the input is a matrix
or numeric
vector.
See also rowMeans()
for the
corresponding function in base R.
For variance estimates, see rowVars()
.
See also the base R version base::rowMeans()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMeans2(mat) colMeans2(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMeans2(mat) colMeans2(mat)
Calculates the median for each row (column) of a matrix-like object.
rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMedians
/
matrixStats::colMedians
.
Returns a numeric
vector
of length N (K).
matrixStats::rowMedians()
and
matrixStats::colMedians()
which are
used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMedians(mat) colMedians(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMedians(mat) colMedians(mat)
Calculates the minimum for each row (column) of a matrix-like object.
rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMins
/
matrixStats::colMins
.
Returns a numeric
vector
of length N (K).
matrixStats::rowMins()
and
matrixStats::colMins()
which are used
when the input is a matrix
or numeric
vector.
For max estimates, see rowMaxs()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMins(mat) colMins(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMins(mat) colMins(mat)
Calculates an order statistic for each row (column) of a matrix-like object.
rowOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowOrderStats(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) colOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colOrderStats(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE)
rowOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowOrderStats(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) colOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colOrderStats(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
which |
An integer index in [1,K] ([1,N]) indicating which order statistic to be returned |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowOrderStats
/
matrixStats::colOrderStats
.
Returns a numeric
vector
of length N (K).
matrixStats::rowOrderStats()
and
matrixStats::colOrderStats()
which are used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- 2 mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowOrderStats(mat, which = 1) colOrderStats(mat, which = 3)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- 2 mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowOrderStats(mat, which = 1) colOrderStats(mat, which = 3)
Calculates the product for each row (column) of a matrix-like object.
rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE) ## S4 method for signature 'ANY' colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE) ## S4 method for signature 'ANY' colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
method |
A character vector of length one that specifies the how the product is calculated. Note, that this is not a generic argument and not all implementation have to provide it. |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowProds
/
matrixStats::colProds
.
Returns a numeric
vector
of length N (K).
matrixStats::rowProds()
and
matrixStats::colProds()
which are used
when the input is a matrix
or numeric
vector.
For sums across rows (columns), see
rowSums2()
(colSums2()
)
base::prod()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowProds(mat) colProds(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowProds(mat) colProds(mat)
Calculates quantiles for each row (column) of a matrix-like object.
rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'ANY' rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'ANY' colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE)
rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'ANY' rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) ## S4 method for signature 'ANY' colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
probs |
A numeric vector of J probabilities in [0, 1]. |
na.rm |
If |
type |
An integer specifying the type of estimator. See
|
digits |
An integer specifying the precision of the formatted
percentages. See |
... |
Additional arguments passed to specific methods. |
useNames |
If |
drop |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowQuantiles
/
matrixStats::colQuantiles
.
a numeric
NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) for
which the J values are calculated.
matrixStats::rowQuantiles()
and
matrixStats::colQuantiles()
which
are used when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowQuantiles(mat) colQuantiles(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowQuantiles(mat) colQuantiles(mat)
Calculates the minimum and maximum for each row (column) of a matrix-like object.
rowRanges(x, ...) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowRanges(x, ...) colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowRanges(x, ...) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowRanges(x, ...) colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
... |
Additional arguments passed to specific methods. |
rows , cols
|
A |
na.rm |
If |
dim. |
An |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowRanges
/
matrixStats::colRanges
.
a numeric
Nx2
(Kx2
)
matrix
, where N (K) is the number of rows (columns) for
which the ranges are calculated.
Unfortunately for the argument list of the rowRanges()
generic function we cannot follow the scheme used for the other
row/column matrix summarization generic functions. This is because
we need to be compatible with the historic rowRanges()
getter
for RangedSummarizedExperiment objects.
See ?SummarizedExperiment::rowRanges
.
matrixStats::rowRanges()
and
matrixStats::colRanges()
which are
used when the input is a matrix
or numeric
vector.
For max estimates, see rowMaxs()
.
For min estimates, see rowMins()
.
base::range()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowRanges(mat) colRanges(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowRanges(mat) colRanges(mat)
Calculates the rank of the elements for each row (column) of a matrix-like object.
rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), preserveShape = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE)
rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), preserveShape = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
ties.method |
A character string specifying how ties are treated. Note that the default specifies fewer options than the original matrixStats package. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
preserveShape |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowRanks
/
matrixStats::colRanks
.
The matrixStats::rowRanks()
function can handle a lot of different
values for the ties.method
argument. Users of the generic function
should however only rely on max
and average
because the other ones
are not guaranteed to be implemented:
max
for values with identical values the maximum rank is returned
average
for values with identical values the average of the
ranks they cover is returned. Note, that in this case the return
value is of type numeric
.
a matrix of type integer
is returned unless
ties.method = "average"
. Ithas dimensions' NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) of the
input x.
matrixStats::rowRanks()
and
matrixStats::colRanks()
which are used
when the input is a matrix
or numeric
vector.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowRanks(mat) colRanks(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowRanks(mat) colRanks(mat)
Calculates the standard deviation of the difference between each element of a row (column) of a matrix-like object.
rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
diff |
An integer specifying the order of difference. |
trim |
A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowSdDiffs
/
matrixStats::colSdDiffs
.
Returns a numeric
vector
of length N (K).
matrixStats::rowSdDiffs()
and
matrixStats::colSdDiffs()
which are
used when the input is a matrix
or numeric
vector.
for the direct standard deviation see rowSds()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSdDiffs(mat) colSdDiffs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSdDiffs(mat) colSdDiffs(mat)
Calculates the standard deviation for each row (column) of a matrix-like object.
rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE)
rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
center |
(optional) the center, defaults to the row means |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowSds
/
matrixStats::colSds
.
Returns a numeric
vector
of length N (K).
matrixStats::rowSds()
and
matrixStats::colSds()
which are used when
the input is a matrix
or numeric
vector.
For variance estimates, see rowVars()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSds(mat) colSds(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSds(mat) colSds(mat)
Calculates the sum for each row (column) of a matrix-like object.
rowSums(x, na.rm = FALSE, dims = 1, ...) colSums(x, na.rm = FALSE, dims = 1, ...)
rowSums(x, na.rm = FALSE, dims = 1, ...) colSums(x, na.rm = FALSE, dims = 1, ...)
x |
An NxK matrix-like object, a numeric data frame, or an array-like object of two or more dimensions. |
na.rm |
If |
dims |
A single integer indicating which dimensions are regarded
as rows or columns to sum over. For |
... |
Additional arguments passed to specific methods. |
This man page documents the rowSums
and colSums
S4 generic functions defined in the MatrixGenerics package.
See ?base::colSums
for the default methods (defined
in the base package).
Returns a numeric
vector
of length N (K).
base::colSums
for the default
rowSums
and colSums
methods.
Matrix::colSums
in the Matrix package
for rowSums
and colSums
methods defined for
CsparseMatrix derivatives (e.g. dgCMatrix objects).
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSums(mat) colSums(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSums(mat) colSums(mat)
Calculates the sum for each row (column) of a matrix-like object.
rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowSums2
/
matrixStats::colSums2
.
Returns a numeric
vector
of length N (K).
matrixStats::rowSums2()
and
matrixStats::colSums2()
which are used
when the input is a matrix
or numeric
vector.
base::sum()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSums2(mat) colSums2(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSums2(mat) colSums2(mat)
Tabulates the values in a matrix-like object by row (column).
rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE)
rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
values |
the values to search for. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowTabulates
/
matrixStats::colTabulates
.
a numeric
NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) for
which the J values are calculated.
matrixStats::rowTabulates()
and
matrixStats::colTabulates()
which
are used when the input is a matrix
or numeric
vector.
base::table()
mat <- matrix(rpois(15, lambda = 3), nrow = 5, ncol = 3) mat[2, 1] <- NA_integer_ mat[3, 3] <- 0L mat[4, 1] <- 0L print(mat) rowTabulates(mat) colTabulates(mat) rowTabulates(mat, values = 0) colTabulates(mat, values = 0)
mat <- matrix(rpois(15, lambda = 3), nrow = 5, ncol = 3) mat[2, 1] <- NA_integer_ mat[3, 3] <- 0L mat[4, 1] <- 0L print(mat) rowTabulates(mat) colTabulates(mat) rowTabulates(mat, values = 0) colTabulates(mat, values = 0)
Calculates the variance of the difference between each element of a row (column) of a matrix-like object.
rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) ## S4 method for signature 'ANY' colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
diff |
An integer specifying the order of difference. |
trim |
A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowVarDiffs
/
matrixStats::colVarDiffs
.
Returns a numeric
vector
of length N (K).
matrixStats::rowVarDiffs()
and
matrixStats::colVarDiffs()
which
are used when the input is a matrix
or numeric
vector.
for the direct variance see rowVars()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowVarDiffs(mat) colVarDiffs(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowVarDiffs(mat) colVarDiffs(mat)
Calculates the variance for each row (column) of a matrix-like object.
rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE)
rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) ## S4 method for signature 'ANY' colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
rows , cols
|
A |
na.rm |
If |
center |
(optional) the center, defaults to the row means. |
... |
Additional arguments passed to specific methods. |
useNames |
If |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowVars
/
matrixStats::colVars
.
Returns a numeric
vector
of length N (K).
matrixStats::rowVars()
and
matrixStats::colVars()
which are used
when the input is a matrix
or numeric
vector.
For standard deviation estimates, see rowSds()
.
stats::var()
.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowVars(mat) colVars(mat)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowVars(mat) colVars(mat)
Calculates the weighted median absolute deviation for each row (column) of a matrix-like object.
rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE)
rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
w |
A |
rows , cols
|
A |
na.rm |
If |
constant |
A scale factor. See |
center |
(optional) the center, defaults to the row means |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedMads
/
matrixStats::colWeightedMads
.
Returns a numeric
vector
of length N (K).
matrixStats::rowWeightedMads()
and
matrixStats::colWeightedMads()
which are used when the input is a matrix
or numeric
vector.
See also rowMads for the corresponding unweighted function.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMads(mat, w = w[1:3]) colWeightedMads(mat, w = w)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMads(mat, w = w[1:3]) colWeightedMads(mat, w = w)
Calculates the weighted mean for each row (column) of a matrix-like object.
rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
w |
A |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedMeans
/
matrixStats::colWeightedMeans
.
Returns a numeric
vector
of length N (K).
matrixStats::rowWeightedMeans()
and
matrixStats::colWeightedMeans()
which are used when the input is a matrix
or numeric
vector.
See also rowMeans2 for the corresponding unweighted function.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMeans(mat, w = w[1:3]) colWeightedMeans(mat, w = w)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMeans(mat, w = w[1:3]) colWeightedMeans(mat, w = w)
Calculates the weighted median for each row (column) of a matrix-like object.
rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
w |
A |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedMedians
/
matrixStats::colWeightedMedians
.
Returns a numeric
vector
of length N (K).
matrixStats::rowWeightedMedians()
and
matrixStats::colWeightedMedians()
which are used when the input is a matrix
or numeric
vector.
See also rowMedians for the corresponding unweighted function.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMedians(mat, w = w[1:3]) colWeightedMedians(mat, w = w)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMedians(mat, w = w[1:3]) colWeightedMedians(mat, w = w)
Calculates the weighted standard deviation for each row (column) of a matrix-like object.
rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
w |
A |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedSds
/
matrixStats::colWeightedSds
.
Returns a numeric
vector
of length N (K).
matrixStats::rowWeightedSds()
and
matrixStats::colWeightedSds()
which are used when the input is a matrix
or numeric
vector.
See also rowSds for the corresponding unweighted function.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedSds(mat, w = w[1:3]) colWeightedSds(mat, w = w)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedSds(mat, w = w[1:3]) colWeightedSds(mat, w = w)
Calculates the weighted variance for each row (column) of a matrix-like object.
rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric' colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'ANY' colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
An NxK matrix-like object. |
w |
A |
rows , cols
|
A |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedVars
/
matrixStats::colWeightedVars
.
Returns a numeric
vector
of length N (K).
matrixStats::rowWeightedVars()
and
matrixStats::colWeightedVars()
which are used when the input is a matrix
or numeric
vector.
See also rowVars for the corresponding unweighted function.
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedVars(mat, w = w[1:3]) colWeightedVars(mat, w = w)
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedVars(mat, w = w[1:3]) colWeightedVars(mat, w = w)