为什么不使用 Ctrl-Shift-F10 重新启动 R 清除我的环境变量? [英] Why doesn't restarting R with Ctrl-Shift-F10 clear my environment variables?

查看:72
本文介绍了为什么不使用 Ctrl-Shift-F10 重新启动 R 清除我的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让 RStudio 在两台不同的机器上工作:我的和同事的.

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

当我使用 Ctrl-Shift-F10 快捷键在 RStudio 中重新启动 R 时,我的所有全局环境变量都消失了.我同事的情况并非如此,他们经常将 rm(list=ls(all=TRUE)) 放入我们的共享代码中.

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.

某处是否有一个可选参数,以便重新启动 R 总是清除环境变量?

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

推荐答案

免责声明:到目前为止,基于 5 个样本大小,这具有 100% 的有效性(由 OP 和 Badger 验证),但我正在录制自从我在其他论坛上看到类似问题(示例 1示例 2) 甚至没有.:)

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. :)

解决方案:转至工具/全局选项/常规&将退出时将工作区保存为 .RData"下拉选项更改为从不".

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

可能的解释:即使您在退出时将工作区保存到 .RData"中选择了询问"选项,Ctrl-Shift-F10 快捷键在会话重新启动之前也不会询问.但是除非您明确选择在退出时从不保存工作区,否则 RStudio 会将其保存在某处以防万一.(不过,我不确定在哪里.我的工作目录中没有与恢复环境相对应的 .RData 文件...)

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...)

这篇关于为什么不使用 Ctrl-Shift-F10 重新启动 R 清除我的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆