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:
> 
> x<-"asdf"
> 
> 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

or

f <- function(value) list(y=value)
asdf <- f(value)

depending on what you are trying to do.

Duncan Murdoch

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to