[R] loading workspace- getting annoying

(Ted Harding) ted.harding at wlandres.net
Thu Oct 21 02:11:19 CEST 2010


On 20-Oct-10 23:37:44, David Winsemius wrote:
> On Oct 20, 2010, at 7:05 PM, sachinthaka.abeywardana at allianz.com.au  
> wrote:
> 
>> I stupidly decided to save my last workspace (a large dataset)
>> and every time I open R it loads it back in. Can I stop this?
>> Also how do you clear variables.
>>
>> Thanks,
>> Sachin
>>
>> --- Please consider the environment before printing this email ---
> 
> You have not shared with us the "at a minimum" information requested  
> in the Posting Guide (although your silly corporate confidential  
> trailer was appended), so take a moment now and read the Posting  
> Guide, please.
> 
> The saved workspace can be deleted. It is a file named .Rdata and in  
> some OSes is "indivisible". Consult your OS documentation (such as it  
> may be) regarding deleting  "invisible" or "dot" or system files.
> 
> You can also start R without any workspace if starting R from a  
> command line and I believe that it is done with the --vanilla setting. 
> Yes, that seems to behave as I expected. (I generally use the Mac GUI.)
> 
>  From a Terminal session:
> david-winsemiuss-mac-pro:~ davidwinsemius$ R --vanilla
> 
> R version 2.11.1 Patched (2010-06-14 r52281)
> ---snipped login information----
> Type 'q()' to quit R.
> 
>  > ls()
> character(0)
> 
> In fact it seems to have also skipped loading my utility functions  
> from .Rprofile as well as skipping the workspace .Rdata file.
> --
> David Winsemius, MD
> West Hartford, CT

The best way to proceed is
(a) Delete .Rdata as David suggests, by whatever method works
    for your system.

(b) Get into the habit of starting R with the command

    R --no-save

    Then R will not prompt you at the end for whether or not
    to sabe the workspace, and you will not do so by mistake.

However, if for a
 particular session you do wich to save the
workspace for later use, then give it a special name (such as
"session01.wsp") and save it by executing the command

  save.image(file = "session01.wsp")

(which as it stands will adopt the defaults for all the other
options -- see '?save.image').

Then, when you want to resume work on that session, with the
workspace you ended up with last time, you should be able to
do this by executing

  load("session01.wsp")

as the first command of the new session.

Finally, if you want to "clear" (by which I guess you mean
"remove") variables (say X, Y, Z1, Z2) or any other R objects
you have created (such as function definitions F1, F2, or
anything else with a name), then you can execute

  rm(X,Y,Z1,Z2,F1,F2)

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 21-Oct-10                                       Time: 01:11:15
------------------------------ XFMail ------------------------------



More information about the R-help mailing list