Thursday, November 22, 2012

Passing-by-reference in R

collection of links to debates/tricks on passing-by-reference in R. http://stackoverflow.com/questions/2603184/r-pass-by-reference
http://www.stat.berkeley.edu/~paciorek/computingTips/Pointers_passing_reference_.html
https://stat.ethz.ch/pipermail/r-devel/2009-January/051899.html
http://homepage.stat.uiowa.edu/~luke/R/references.html
http://r.789695.n4.nabble.com/Pass-By-Value-Questions-td2331565.html

My take on that is to use new Reference Classes if there is a need for complex mutable objects.
Use of environments to pass-by-reference is considered as a hack.
E.g. (from Robert Gentleman's book)
e1 = new.env()
f = function(x) {x+z}
enironment(f) = e1
e1$z = 10
f(1)
Output is 11
Note, however, after deleting e1, f does not go away.
rm(e1)
f is still around

Second point is to take a look at data.frame by pass-by-reference using "ref" and "plyr" packages.

Checking font availability on Mac   fc-list : family | grep "Fira Code"   or   system_profiler -json SPFontsDataType | grep \...