On Wed, Jul 15, 2009 at 10:41 AM, Duncan Murdoch<murd...@stats.uwo.ca> wrote:
> Given two .RData files, you can load them into separate environments. > Dealing with conflicting variables names is another issue, of course. > > For example: > > DataSet1 <- new.env() > load( "somefile", envir=DataSet1) > > Now use ls(DataSet1) to see what you've got, repeat for DataSet2, etc. You > can get a variable as DataSet1$VariableA. As an alternative to loading you can attach the RData and get variables using "get". Create a couple of RData files with an 'x' in them: > x=1 > save(x,file="x1.RData") > x=2 > save(x,file="x2.RData") > q() Now in a new R session: > attach("x1.RData",warn=FALSE) > attach("x2.RData",warn=FALSE) > get("x",pos="file:x1.RData") [1] 1 > get("x",pos="file:x2.RData") [1] 2 I've used warn=FALSE to suppress the warnings that attach() gives you when objects attached mask other objects of the same name. You can also detach() these things once you're done with them. Barry ______________________________________________ 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.