Message-ID: <3ED8E594.3080100@pdf.com>
Date: 2003-05-31T17:25:40Z
From: Spencer Graves
Subject: parse on left hand side of R assignment
Have you considered the following:
> myList <- list()
> iteration <- 1
> varName <- paste("run",iteration,sep="")
> myList[[varName]] <- "aColumn"
> myList
$run1
[1] "aColumn"
hth. spencer graves
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
>
> I want to take some existing variable "aColumn" and use the name
> "varName" name for it and put it into a list "myList". That use fails
> with this error:
>
> Error: couldn't find function "(<-"
>
> I've tried many variations on the theme.
>
> If I could do this with a data frame, I would be just as happy. Right
> now I'm using a list rather than a data frame because not all columns
> are of the same length. But I can work around that.
>