[R] how to automatically create objects with names from a string list?

From: Mark Farnell <mark.farnell_at_gmail.com>
Date: Wed, 04 Jun 2008 17:15:47 +1200


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_at_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. Received on Wed 04 Jun 2008 - 06:13:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 04 Jun 2008 - 19:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive