You can use either assign or eval. Something like
> name <- c("foo", "bar", "baz") > for (i in 1:length(name)) assign(name[i],i) --- On Wed, 4/6/08, Mark Farnell <[EMAIL PROTECTED]> wrote: > From: Mark Farnell <[EMAIL PROTECTED]> > Subject: [R] how to automatically create objects with names from a string > list? > To: R-help@r-project.org > Received: Wednesday, 4 June, 2008, 3:15 PM > Suppose I have a string of objects names: > > name <- c("foo", "bar", > "baz") > > and I would like to use a for loop to automatically create > three > objects called "foo", "bar" and > "baz" accordingly. Then how can this > be done" (so that in the workspace, foo = 1, bar = 2 > and baz=3) > > for (i in name) { > ..... > } > > Thanks! > > Mark > > ______________________________________________ > R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.