Re: [R] Symbolic references - passing variable names into functions

2009-08-12 Thread Gabor Grothendieck
Returning the changed value as in Erik's answer is probably the most common and R-like solution but here are two others. The assign/get approach is perhaps the closest to what you are asking for. # replacement function approach # replacement function - rhs is formula whose response is assigned t

Re: [R] Symbolic references - passing variable names into functions

2009-08-12 Thread Erik Iverson
g [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Shenkin Sent: Wednesday, August 12, 2009 9:27 AM To: r-help@r-project.org Subject: [R] Symbolic references - passing variable names into functions Hello All, I am trying to write a function which would operate on columns of a dataframe specifi

[R] Symbolic references - passing variable names into functions

2009-08-12 Thread Alexander Shenkin
Hello All, I am trying to write a function which would operate on columns of a dataframe specified in parameters passed to that function. f = function(dataf, col1 = "column1", col2 = "column2") { dataf$col1 = dataf$col2 # just as an example } The above, of course, does not work a