On Sat, 31 May 2003, Paul E. Johnson wrote:

> I keep finding myself in a situation where I want to calculate a
> variable name and then use it on the left hand side of an assignment.
> For example
>
> iteration <- 1
> varName <- paste("run",iteration,sep="")
> myList$parse(text=varName) <- aColumn
>

In this particular case you can just use

myList[[varName]]<-aColumn.

I don't think you can (easily) use assign, despite the suggestion -- it
doesn't dispatch assignment methods.

If you wanted to do something of this sort for which the above didn't work
you could also learn about substitute()
  eval(substitute(myList$newColumn<-aColumn),
     list(newColumn=as.name(varName)))
as an alternative to parse().

        -thomas

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to