[R] Loading data into a list of environments

From: Powell, Jeff <Jeff.Powell_at_wur.nl>
Date: Sat, 31 May 2008 22:44:01 +0200

Dear All,

Thanks to an answer which I received from a previous post, I'm now able to create a series of environments using the following:

  nmes <- c("en1", "en2", "en3")
  for(i in nmes) assign(i, new.env(parent = .GlobalEnv))

My next question is how, using "load", can I automatically place data into each of these newly created environments.

The following, and variations thereof, does not work:

  nmes <- c("en1", "en2", "en3")
  for(i in nmes) load(file = "/home/testData/Data.RData", i)

I've tried, among other attempts, to use "as.environment(i)" without success. My "i" is seen as a character, but I want it to be seen as the environment which it represents.

Kind regards,

Alexanderveld 5
2585 DB Den Haag
The Netherlands

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 Mon 02 Jun 2008 - 04:19:16 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 Mon 02 Jun 2008 - 04:30:37 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