[R] pass by reference -- how to do it

Robert Dodier robert_dodier at yahoo.com
Tue Feb 17 22:23:58 CET 2004


Pass by reference appears to be a topic which comes up
from time to time, but I wasn't able to find something in
the R-help archives which tells how to accomplish it.

I have a problem that you may have seen before -- R runs
out of memory when processing large matrices. Part of the
problem for me is that I am using some large matrices as
function arguments, and these are modified, which leads 
to allocating copies of the matrices. 

I would like to do the modification "in place" so that
a copy is not required. Thanks for any light you can shed
on this.

If you're tempted to tell me "you don't really want to do that" --
let me save you the trouble. You are so very right! Indeed I
don't want to have pass by reference variables. OTOH I don't
want R to come to a dead halt at an inconvenient time either.

Thanks for your help,
Robert Dodier

More information about the R-help mailing list