r-如何在没有来源的情况下调用littler ~/.Rprofile



似乎当我从命令行调用littler时,它将获取~/.Rprofile。有没有办法阻止它获取~/.Rprofile?

这是双向的——我们现在阅读~/.Rprofile在很大程度上是因为想要这个功能的用户,而不是不想要它:(

但有一个(简单易行(的解决方案:使用interactive()。见证人:

edd@rob:~$ r -e 'print(interactive())'
[1] FALSE
edd@rob:~$ r -i -e 'print(interactive())'
Please do not apply R like a magic answers box, because you can mislead
others and cause harm.
-- Jeff Newmiller (about how much statistical knowledge is needed 
for using R)
R-help (May 2016)
[1] TRUE
edd@rob:~$ 

那么这里发生了什么首先,我们测试了interactive()。它返回FALSE。这是默认设置。什么也没发生。

第二次,我将-i开关添加到执行交互模式。它打印了TRUE,但更多。为什么?

我的~/.Rprofile本质上看起来像这个

## header with a few constant settings, mostly to options()
## TZ setting and related
local({     # start of large block, see Rprofile.site
if (interactive()) {
if (requireNamespace("fortunes", quietly=TRUE)) {
print(fortunes::fortune()) 
#more stuff
}
})

它管理控制台上Emacs/ESS和RStudio中的交互式R会话,以及来自crontab的非交互式r调用。

简而言之:是的,它总是被阅读。但是,是的,您也可以跳过不希望执行的部分。

相关内容

最新更新