如何在不采购 ~/.Rprofile 的情况下调用 littler?
How to call littler without sourcing ~/.Rprofile?
似乎当我从命令行调用 littler
时,它将 source ~/.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
.[=21 的非交互式 r
调用=]
简而言之:是的,它总是被阅读。但是,是的,您也可以跳过不想执行的部分。
似乎当我从命令行调用 littler
时,它将 source ~/.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
.[=21 的非交互式 r
调用=]
简而言之:是的,它总是被阅读。但是,是的,您也可以跳过不想执行的部分。