[R] Saving workspace image
Marc Schwartz
MSchwartz at medanalytics.com
Wed Oct 8 03:06:11 CEST 2003
On Tue, 2003-10-07 at 19:00, Ted.Harding at nessie.mcc.ac.uk wrote:
> Hi folks,
>
> On quitting R with q(), is it possible to save the workspace
> to a directory other than the one R was started from?
>
> (I sometimes have a project "master" directory with the major
> R code and data in that directory, but divisions of the project
> having their specific stuff in sub-directories. So if I quit while
> running a sub-project, I'd like to save the workspace back into its
> sub-directory. I see that this could be achieved by starting R in that
> sub-directory, and invoking "master" code as source("../whatever"),
> but this would be a lot less convenient than doing it the other way
> round).
>
> With thanks,
> Ted.
Ted,
Use:
setwd("PathToDir")
prior to quitting. That will set your working directory.
Alternatively, you can always use:
save.image("PathToDir/.RData")
to save the workspace image explicitly where you want it.
See ?setwd and ?save.image
HTH,
Marc Schwartz
More information about the R-help
mailing list