Disable saving history

不问归期 提交于 2019-11-27 17:19:24

问题


Is it possible to disable saving command history / session in R by default ? I really hate those .RData and .RHistory files !!


回答1:


Just start up R with --no-save. See R --help.

Add this to your shortcuts (in Windows for example this is under "Target" when you right-click on the shortcut and choose properties).




回答2:


If you are using an R gui, an alternative and quite nice approach, due to Brian Ripley, (see here), is to put the following lines in your 'R_HOME/etc/Rprofile.site' file:

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

One note of caution: this won't work when you invoke R from the command-line. In that case, just use the --no-save argument described in @mdsumner answer.

To learn more about 'Rprofile.site', and '.Rprofile' (an optional per-directory config file), see the always useful ?Startup help file.




回答3:


If you're using RStudio, you can simply disable in settings.

Go to Tools -> Global options -> General and un-tick always save history.




回答4:


Even more flexible (Windows), add R and RStudio to your right-click menu so you can start in any directory

R-Gui: save the following in a file rguihere.reg, and double-click

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\""

RStudio

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\""


来源:https://stackoverflow.com/questions/10098189/disable-saving-history

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!