[R] naive question about using an object as the name of another object
murdoch at stats.uwo.ca
Fri May 18 12:49:28 CEST 2007
On 17/05/2007 10:11 PM, Andrew Yee wrote:
> This is a dumb question, but I'm having trouble finding the answer to this.
> I'd like to do the following:
> and then have
> the object x.y become automatically converted/represented as asdf.y (sort of
> akin to macro variables in SAS where you would do:
> %let x=asdf and do &x..y)
> What is the syntax for having x represented as "asdf" in x.y ?
You can use assign( gsub("x", x, "x.y"), x.y ), but this is not a normal
thing to do in R programs: R is not SAS. You should investigate using a
list and setting a member of it, e.g.
asdf$y <- value
f <- function(value) list(y=value)
asdf <- f(value)
depending on what you are trying to do.
More information about the R-help