[R] Efficiency of local functions

Thomas Lumley thomas at biostat.washington.edu
Thu Mar 30 17:58:51 CEST 2000

On Thu, 30 Mar 2000, Peter Holzer wrote:

> Dear R-users
> In order to speed up the performance of my program I tried to make a
> function f2 (that is only called from function f1) local to f1. In that way I
> pass one argument less to f2, a huge matrix. (This matrix isn't changed
> inside f2, so - afaik - it is passed by reference and size doesn't matter.)
> Still I would have expected that f1 would be a little faster, but the
> opposit happened:

No, it should be slightly slower.  When f2 is declared inside f1 it has to
be parsed each time f2 is called.  Your figures may well be equal within
experimental error, though.


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