Skip to content
Prev 32719 / 398526 Next

parse on left hand side of R assignment

At 11:57 AM 5/31/2003 -0500, Paul E. Johnson wrote:
Dear Paul,

I don't think that assign() will work in this context, but I may be wrong.

One way to proceed is with eval() and parse(), assembling the command to be 
executed as a text string; for example,

eval(parse(text=paste("myList$", varName, " <- aColumn", sep=""))), though 
you do have to be careful about the environment in which the expression is 
evaluated -- see the envir argument to eval.

I hope that this helps,
  John


-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox