[R] memory tricks

Steve Oncley oncley at atd.ucar.edu
Tue Mar 2 17:56:44 CET 1999


Perhaps I've missed this in the FAQ, but has someone documented any tricks
which can be used in R to optimize memory usage/execution time?  For S+,
StatSci used to recommend:
1. Avoid "for" loops whenever possible.
2. In "for" loops, have a simple expression, such as TRUE, as the last 
statement.
3. Allocate memory for a vector/array at one time, rather than building it
up in a "for" loop using c(), rbind(), etc.
4. Execute code which manipulates large objects within a function, rather
than directly from the command line.

Should these practices help when using R?  Are there others which users 
should know about?

Thanks...Steve Oncley
NCAR/ATD
PO Box 3000
Boulder CO 80307-3000 USA
oncley at ucar.edu
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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