[R] R function calling: efficiency of different alternatives
rdiaz at cnio.es
Tue Apr 1 12:02:08 CEST 2003
I have a piece of code, call it "FA", that will be called thousands of times
in a typical run of function "FB". I can:
a) define FA as a function outside of FB (in the global environment), and call
b) define FA as a function inside the body of FB and call it;
c) "expand inline" FA inside FB.
FA mainly does data frame subsetting, runs svd's, and calls compiled C++ code.
I think I recall reading something about differences in efficiency between
those three approaches, but I can't find the information (I've searched the
email archives, Venables & Ripley's "S programming" and MASS, the R manuals,
and Burn's "S Poetry").
Are there any real performance differences?
(I'd personally prefer b) since these functions will hopefully become a
contributed package, and FA is not supposed to be used directly by an end
user. I am aware of scoping differences between the three approaches, but
that is not my main concern now).
Centro Nacional de Investigaciones Oncológicas (CNIO)
(Spanish National Cancer Center)
Melchor Fernández Almagro, 3
28029 Madrid (Spain)
More information about the R-help