Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't restarting R with Ctrl-Shift-F10 clear my environment variables?

Tags:

r

rstudio

I have RStudio working on two different machines: mine and a colleague's.

When I restart R in RStudio with the Ctrl-Shift-F10 shortcut, all my global environment variables go away. Not so for my colleague's, who frequently puts rm(list=ls(all=TRUE)) in our shared code.

Is there an optional parameter somewhere, so that restarting R always clears environment variables?

like image 237
lebelinoz Avatar asked Aug 24 '17 22:08

lebelinoz


1 Answers

Disclaimer: this has 100% effectiveness based on a sample size of 5 so far (validated by OP & Badger), but I'm recording it for posterity since other forums where I've seen similar questions (example 1, example 2) don't even have that. :)

Solution: Go to Tools / Global Options / General & change the "Save workspace to .RData on exit" dropdown option to "Never".

Possible interpretation: Even if you chose the 'Ask' option in "Save workspace to .RData on exit", Ctrl-Shift-F10 shortcut won't ask before the session gets restarted. But unless you explicitly chose to NEVER save workspace on exit, RStudio will keep it somewhere just in case. (I'm not sure where, though. There's no .RData file in my working directory corresponding to the restored environment...)

like image 141
Z.Lin Avatar answered Sep 28 '22 00:09

Z.Lin