On 2010-09-26, at 9:21 AM, Prof Brian Ripley wrote: > 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)).
Fair enough. > 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. Well, making a package for what amounts to a couple of aliases and utility functions seems like overkill, and in any case I haven't the faintest idea how to make a package. I just want a couple of small custom things to always be available for me in R. I got this idea from a website that showed somebody's .Rprofile file, which defined loads upon loads of custom functions; maybe that other person led me in a bad direction, but it's not immediately obvious to me why doing this is a Bad Idea, and other example .Rprofiles on the web often seem to do the same. Isn't the whole point of the .Rprofile file to customize your default R environment to fit your needs? Starting a new session sounds more useful than clearing the workspace, I agree. I'd be happy if the "Clear Workspace" menu command morphed into a "Reset Session" menu command, or some such, defined as "give me a session/workspace/etc. identical to what I would get if I quit and relaunched R GUI." I would actually just quit and relaunch the app, except 1) that's slow, and 2) that closes all my open source file windows, which is a hassle. Ben Haller McGill University _______________________________________________ R-SIG-Mac mailing list R-SIG-Mac@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac