[R-SIG-Mac] Clear Workspace and .Rprofile
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Sep 26 15:21:29 CEST 2010
On Sun, 26 Sep 2010, Ben Haller wrote:
> Hi all. I recently made myself a .Rprofile file, and I have just
> discovered two oddities with this in the R GUI. On the one hand,
> when I do "Clear Workspace" (from the Workspace menu) it doesn't
> clear out the .First function that my .Rprofile defined, which is
> surprising. On the other hand, it also doesn't re-run my .Rprofile,
> which I would have expected, since to me the point of "Clear
> Workspace" is to give a fresh workspace identical to the one I get
> when I quit and re-launch the R GUI app.
> I don't know enough about the internals of R to assert that these
> are bugs; but I can say that it's annoying to me that Clear
> Workspace gives me a workspace in which my .Rprofile stuff is not
> defined. What's the recommended way to deal with this?
I'd say not clearing .First is a bug: the menu item executes
[[REngine mainEngine] executeString: @"rm(list=ls())"];
and that should be rm(list=ls(all=TRUE)).
However, if you ask the workspace to be cleared, it should be clear.
The unanswered question is why you are using .Rprofile to create
objects in the workspace -- sounds as if you want to put them in an
attached environment (e.g. via a package) -- and people normally work
hard to ensure that .Rprofile leaves no objects there.
Beyond that, one could question the need for a 'Clear Workspace' menu
item. It does not start a new session and there are some many
stateful variables (e.g. the search() path) not part of the workspace
that starting a new session is much more common.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-SIG-Mac