[Rd] Best practices for writing R functions

Hadley Wickham hadley at rice.edu
Fri Jul 22 21:45:32 CEST 2011


> But beware that a function makes a copy of the argument as soon as you try to modify something in that argument. So, for example, if you have a big list object as an argument and are going to modify one element in the list, you will save memory by making a local copy of the single element and modifying that. However, as others have said, I would not worry until you find there is a problem.

That's generally good practice in R - always modify the simplest
object possible.

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-devel mailing list