[R] performance question
Thomas Lumley
tlumley at u.washington.edu
Fri Sep 26 18:00:53 CEST 2003
On Fri, 26 Sep 2003, Axel Benz wrote:
> Hi,
> I am about to write functions for multivariate kernel densitiy estimation
> with mixed categorical and continuous date (accoring to Jeff Racine and Qi
> Li), and the leave-one-out window esitmation needs a lot of computation.
> I am now optimizing the code performance and therefore fhe following
> questions:
>
> As R uses call-by-value for functions, is it computational expensive to pass
> large matrices in function arguments?
No, as long as they are not modified. R doesn't make actual copies if it
knows they aren't needed, it just creates a reference to the original
object.
> (i.e. are they really copied and does this need much computing time?) Is it
> maybe better to work with locally visible variables and nested functions in
> the optimized code?
It probably won't make a detectable difference. Looking up a variable is
microscopically quicker if it is local (eg passed as a parameter), but you
need fairly extreme cases for this to be noticeable.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list