[R] Row means of matrix.

David Winsemius dwinsemius at comcast.net
Sat Aug 18 07:55:08 CEST 2012


On Aug 17, 2012, at 8:28 PM, Yingwei Lee wrote:

> m=matrix(c(1:4, c(0, 0, 0, 0), c(1, 0, 1, 1)), nc=4, byrow=TRUE)

is.na(m) <- m==0
rowMeans(m, na.rm=T)
#[1] 2.5 NaN 1.0

-- 
David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list