rowMedians: Calculates the median for each row (column) in a matrix
Description
Calculates the median for each row (column) in a matrix.Usage
rowMedians(x, na.rm=FALSE, ...)
colMedians(x, na.rm=FALSE, ...)
Arguments
na.rm
If TRUE
, NA
s are excluded first, otherwise not. Details
The implementation of rowMedians()
is optimized for both
speed and memory.
To avoid coercing to double
s (and hence memory allocation), there
is a unique implementation for integer
matrices, that is, if
x
is an integer
matrix
, then rowMedians(as.double(x))
requires three times the memory compared with rowMedians(x)
.
Currently, colMedians(x)
is calling rowMedians(t(x))
.See Also
See rowMeans()
in colSums
().