[R] Data frames, passing by value, and performance

gschultz at scriptpro.com gschultz at scriptpro.com
Mon May 24 16:29:36 CEST 2010


I understand that everything passed to an R function is passed "by
value".  This would seem to include data frames, which my current
application uses heavily, both for storing program inputs, and holding
intermediate and final results.  In trying to get greater performance
out of my R code, I am wondering if there is any clean way to access
data frames without having them copied all the time.  Or is my only
option to make them global, and write to them using <<-  ?

I have considered using matrices, but I like the self-documenting aspect
of data frame column names.  Input/output to disk is not the issue here,
as that does not take long in my case.  It's just the internal parameter
passing that I'm concerned about.

(I've checked R-FAQ, R-lang and searched the R-help archives, but didn't
see any specific mentions of this.)

Thanks.

Grant Schultz



More information about the R-help mailing list