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, 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() 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)).

Value

Returns a numeric vector of length N (K).

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

See Also

See rowMeans() in colSums().


[Package matrixStats version 0.1.6 Index]