[R-SIG-Finance] Use apply/lapply/tapply functions
gmain.20.phftt at xoxy.net
Wed Sep 3 23:22:03 CEST 2008
Jorge Nieves wrote:
> So in short, there is really not much computational advantage in terms of time savings when using apply versus for loop, right? Is it fair to say advantage of apply over "for loops" is the "verorizing' and compactness of the code?
Um, no. Or rather, you're half right. apply() and it's siblings are
mere syntactic sugar to help you write clean code. They are implicit
loops that still have to loop over whatever it is you would loop over in
an explicit loop. Vectorization is something else altogether and is a
big win if you can use it. It can eliminate loops altogether, or rather
push them down into a hyper-optimized numerical library.
More information about the R-SIG-Finance