Learn R Programming

matrixStats (version 0.1.5)

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

x
na.rm
If TRUE, NAs are excluded first, otherwise not.
...
Not used.

Value

Details

The implementation of rowMedians() is optimized for both speed and memory. To avoid coercing to doubles (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().