## Speed comparison on a large matrix:
## rowVarsC is much faster than apply().
MAT <- matrix(rnorm(10 * 100000), ncol = 10)
system.time(RES1 <- apply(MAT, 1, var))
system.time(RES2 <- rowVarsC(MAT))
all.equal(RES1, RES2)
Run the code above in your browser using DataLab