似乎当我从命令行调用littler时,它将生成~/.Rprofile。有什么办法阻止它采购~/..Rprofile吗?
发布于 2020-04-14 00:48:56
它是双向的--我们现在正在阅读~/.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
}
})这控制着我在控制台上的交互R会话,在Emacs/ESS中,在RStudio中,以及我来自(比方说,crontab )的非交互式r调用。
所以简单地说:是的,它总是被读着。但是是的,您也可以跳过不想执行的部分。
https://stackoverflow.com/questions/61198947
复制相似问题