rowMedians {matrixStats} | R Documentation |
Calculates the median for each row (column) in a matrix
Description
Calculates the median for each row (column) in a matrix.
Usage
rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x),
..., useNames = TRUE)
colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x),
..., useNames = TRUE)
Arguments
x |
|
rows , cols |
A |
na.rm |
|
dim. |
An |
... |
Not used. |
useNames |
If |
Details
The implementation of rowMedians()
and colMedians()
is
optimized for both speed and memory. To avoid coercing to
double
s (and hence memory allocation), there is a
special implementation for integer
matrices. That is,
if x
is an integer
matrix
,
then rowMedians(as.double(x))
(rowMedians(as.double(x))
) would
require three times the memory of rowMedians(x)
(colMedians(x)
), but all this is avoided.
Value
Returns a numeric
vector
of
length N (K).
Author(s)
Henrik Bengtsson, Harris Jaffee
See Also
See rowWeightedMedians()
and
colWeightedMedians()
for weighted medians.
For mean estimates, see rowMeans2()
and
rowMeans()
.