27

是否可以默认禁用在 R 中保存命令历史记录/会话?我真的很讨厌那些 .RData 和 .RHistory 文件!

4

4 回答 4

21

如果您使用的是 RStudio,您可以简单地在设置中禁用。

转到工具 -> 全局选项 -> 常规并取消勾选始终保存历史记录。 在此处输入图像描述

于 2018-12-28T08:11:01.217 回答
15

只需用--no-save. 见R --help

将此添加到您的快捷方式中(例如,在 Windows 中,当您右键单击快捷方式并选择属性时,它位于“目标”下)。

在此处输入图像描述

于 2012-04-11T00:11:27.760 回答
7

如果您使用的是 R gui,由于 Brian Ripley(见此处),另一种非常好的方法是将以下几行放入您的“R_HOME/etc/Rprofile.site”文件中:

q <- function (save = "no", status = 0, runLast = TRUE)
.Internal(quit(save, status, runLast))

注意一点:当您从命令行调用 R 时,这将不起作用。在这种情况下,只需使用--no-save@mdsumner 答案中描述的参数。

要了解有关“Rprofile.site”和“.Rprofile”(可选的每个目录配置文件)的更多信息,请参阅始终有用的?Startup帮助文件。

于 2012-04-11T07:08:00.027 回答
1

更灵活(Windows),将 R 和 RStudio 添加到您的右键菜单中,以便您可以在任何目录中启动

R-Gui:将以下内容保存在文件 rguihere.reg 中,然后双击

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\RGui]
@="R Gui here"

[HKEY_CLASSES_ROOT\Folder\shell\RGui\command]
@="cmd.exe /c \"pushd  %L &&start rgui --no-restore --no-save\""

工作室

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\RStudio]
@="RStudio here"

[HKEY_CLASSES_ROOT\Folder\shell\RStudio\command]
@="cmd.exe /c \"pushd %L &&start C:\\PROGRA~1\\RStudio\\bin\\rstudio.exe\""
于 2012-04-11T09:29:25.203 回答