powered by
colMedians(x) rowMedians(x)
med, colVars, colMeans (buit-in R function)
x <- matrix( rnorm(100 * 1000), ncol = 1000 ) system.time( a <- apply(x, 2, median) ) system.time( b1 <- colMedians(x) ) all.equal(as.vector(a), b1)
Run the code above in your browser using DataLab