[R] problem with do.call

Ernesto Jardim ernesto at ipimar.pt
Thu Apr 11 11:51:12 CEST 2002


Hi

This was not my understanding. I thougth that if you can use functions
like apply and similar instead of for loops your code will be faster.
Basicly relying on these functions code which is (should be) optimized
for speed.

If what you're saying is true then using functions like apply is a
matter of simplicity and not speeding up the code. 

Is this correct ?

Thanks

EJ

On Wed, 2002-04-10 at 17:41, Thomas Lumley wrote:
> On 10 Apr 2002, Ernesto Jardim wrote:
> >
> > define "vectorize function"
> >
> 
> Many R functions can operate on a vector of parameter values, eg
> 
> log(10,c(2,e,10)) gives the log of 10 to base 2, e, and 10
> 
> If your function can do this, you can construct a set of vectors
> containing all your parameter values (expand.grid() is useful for this)
> and evaluate your function once.
> 
> This can be faster than for() loops when much of the iteration is done in
> compiled code.  If the iteration has to be done in interpreted code then
> you can't really speed up the for() loops.  You can hide the loops with
> the apply() functions, which may make your code more readable, but it
> won't typically speed it up.
> 
> 
> 	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list