[R-SIG-Finance] Use apply/lapply/tapply functions

Rob Steele gmain.20.phftt at xoxy.net
Wed Sep 3 23:22:03 CEST 2008

Jorge Nieves wrote:
> Ok...
> 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?
> Thanks,
> Jorge

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.

Good luck.

More information about the R-SIG-Finance mailing list