[R] Two R sessions?
Thomas Lumley
tlumley at u.washington.edu
Tue Apr 2 19:44:07 CEST 2002
On Mon, 1 Apr 2002, Paul Y. Peng wrote:
> Hi R users,
>
> I am still a relatively new R user migrated from S+. I wonder in R
> how do you handle one difference between R and S+. S+ saves objects
> as different files in .Data directory while R saves all objects in
> a big file .RData. In S+, I can start two S+ sessions from the same
> directory and work simultaneously as long as new objects in the two
> sessions are not in the same names. This is particularly useful in
> simulation studies. However, this method fails for R. I am curious
> how other R users handle this thing in R. Naively, I can copy .Rdata
> into another directory and then start another R session there. When
> the job is done, dump all new objects in one .Rdata into the other
> .Rdata. But maybe someone has a better way to do it.
You can save the workspace to a file with a different name using the
save.image() function. That way you could have oneproject.rdata,
and anotherproject.rdata holding the two sets of data. You could also have
a third file with objects you wanted to use in more than one project, say
commonobjects.rdata.
You might then do
R> load("oneproject.rdata")
R> attach("commonobjects.rdata")
R> work, work, work
R> save.image("oneproject.rdata")
R> q("no")
so that the common objects aren't saved into "oneproject.rdata" but the
rest of your work is.
> BTW, why does R save objects in one big file rather than as different
> files in a directory as S+ does?
>
Partly because it's harder to separate objects in R. The fact that
functions and model formulas have attached environments means that you may
have to keep quite large collections of objects together in an R file.
I actually think it's easier to keep track of things the R way -- you
decide when things go in the same file, whereas with S-PLUS it depends on
what your working directory happens to be. This might just indicate
successful brainwashing, though.
-thomas
Thomas Lumley Asst. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list