如何在R中增加命令历史的长度?

在R中,我喜欢使用反向搜索(ctrl r)重做不常见但复杂的命令,而无需脚本.通常,我将执行许多其他命令之间的命令历史丢弃旧的命令.如何更改命令历史记录的默认长度?
最佳答案
这是平台和控制台的具体.从帮助?保存历史:

There are several history mechanisms available for the different R
consoles, which work in similar but not identical ways…

The history mechanism is controlled by two environment variables:
R_HISTSIZE controls the number of lines that are saved (default 512),
and R_HISTFILE sets the filename used for the loading/saving of
history if requested at the beginning/end of a session (but not the
default for these functions). There is no limit on the number of lines
of history retained during a session, so setting R_HISTSIZE to a large
value has no penalty unless a large file is actually generated.

所以理论上你可以读取和设置R_HISTSIZE:

Sys.getenv("R_HISTSIZE")
Sys.setenv(R_HISTSIZE = new_number)

但实际上,这可能是也可能没有任何效果.

参见?Sys.setenv和?EnvVar

转载注明原文:如何在R中增加命令历史的长度? - 代码日志