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