> system.time(sapply(rnorm(1000000,0,1), function (x) round(x,2)))
user system elapsed
2.78 0.11 2.89
> system.time(round(rnorm(1000000,0,1),2))
user system elapsed
0.29 0.00 0.30
I was trying this out after reading the answers to the R tips question. I did not expect sapply to be order of magnitude slower than the equivalent composite function in the above case. Does anyone know why this is the case? If i understand correctly sapply will vectorize and be near optimally fast.