[R] To improve my understanding of workspaces

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Fri Mar 10 14:25:41 CET 2006

I use emacs and ESS to develop the scripts. The new releases of R has
the script function already in built.

Typically I keep all the data and scripts related to a project in its
own folder, so I have minimal worry about paths.

To save large and associated objects, I use 
   save(x, y, z, file="lala.rda", compress=TRUE) 
and then to load x, y, z in another session or workspace I use

To save small dataframes and matrices, I use 
   write.table(mat, file="lala.txt", sep="\t") 
and to read it back I use
   mat <- read.delim(file="lala.txt", row.names=1)

The problem with .RData (via quit or save.image), is that it keeps all
intermediate objects which can be unnecessarily bloated and confusing.
Further you will have difficulty distinguishing one .RData from the
other by looking at the filename alone.

Regards, Adai

On Fri, 2006-03-10 at 06:58 -0500, Kevin E. Thorpe wrote:
> Hello.
> I have grown accustomed to the .Data directory in S-Plus and so when
> I came to R I continued that behaviour by saving my workspaces at
> the end of each R session.  So, I have saved workspaces in various
> directories where I have used R just as I would have had various
> .Data directories where I had used S-Plus.
> I have seen comments on the list, most recently from Prof. Ripley
> that they don't routinely save their workspaces in this way.
> So my questions are:
>    1. What do people do instead to manage projects?
>    2. Is there an "official" recommendation?
>  From my reading I have learned that you can save data frames
> (and other objects?) to disk and then attach them.  Does this
> save memory?  If I have read correctly, I understand that
> everything in the workspace is in memory, but haven't been able
> to determine if objects in the search path are as well.
> Kind Regards,
> Kevin

More information about the R-help mailing list