rowMedians: Calculates the median for each row (column) in a matrix

Description Usage Arguments Details Value Author(s) See Also

Description

Calculates the median for each row (column) in a matrix.

Usage

1
2
 rowMedians(x, na.rm=FALSE, ...)
 colMedians(x, na.rm=FALSE, ...)

Arguments

x

A numeric NxK matrix.

na.rm

If TRUE, NAs are excluded first, otherwise not.

...

Not used.

Details

The implementation of rowMedians() and colMedians() is optimized for both speed and memory. To avoid coercing to doubles (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 rowMedians() and colMedians() for weighted medians. For mean estimates, see rowMeans() in colSums().


matrixStats documentation built on May 2, 2019, 4:52 p.m.