Using a string as a variable name
On 10/20/2006 7:28 PM, Jason Horn wrote:
Is it possible to use a string as a variable name? For example: foo<="var1" frame$foo # frame is a data frame with with a column titled "var1" This does not work, unfortunately. Am I just missing the correct syntax to make this work?
Yes, you want foo <- "var1" frame[ ,foo] (i.e. return the foo column from frame, indexing frame as though it was a matrix). Duncan Murdoch