在R CMD构建中使用--vanilla [英] Using --vanilla with R CMD build
问题描述
According to the document Writing R Extensions ss 1.3 "R CMD check and R CMD build run R with --vanilla, so none of the user's startup files are read".
这似乎在我的安装中没有发生.我发现我的R版本(在Mac上为2.15.1)将程序包加载到.Rprofile
中-我对此很确定,因为我已经设法通过在.Rprofile
中添加library(hobblegobble)
来可靠地破坏它.
This doesn't seem to happen on my installation. I have found that my version of R (2.15.1 on Mac) loads the packages in my .Rprofile
- i am pretty sure about this, as i've managed to reliably break it by adding library(hobblegobble)
to my .Rprofile
.
这有关系吗?如果是这样,我总是应该更喜欢用
does this matter? If so, should i always prefer to build packages with
R --vanilla CMD build
谢谢
推荐答案
如果.Rprofile加载了您试图构建(或安装)的软件包,则可以使用R --vanilla CMD build myPackage
或R --vanilla CMD INSTALL --build myPackage
.
You can use either R --vanilla CMD build myPackage
or R --vanilla CMD INSTALL --build myPackage
if your .Rprofile loads packages that you are trying to build (or install).
我知道使用--vanilla
的唯一缺点是终端的完成(即,在您点击 tab 时为您完成了软件包目录名称)在键入时可能无法正常工作包目录的路径.
The only drawback I am aware of to using --vanilla
is that the terminal's completion (i.e. having the package directory name completed for you when you tap tab) may not work while you're typing the path to the package directory.
但是,更好的解决方案可能是将if (interactive()) {}
包装在您只希望在交互式会话中运行的.Rprofile中的代码周围.例如library
或require
调用.
However, a better solution may be to wrap if (interactive()) {}
around code in your .Rprofile that you only want to be run in interactive sessions. e.g. library
or require
calls.
如果您的.Rprofile文件具有if (interactive()) library(hobblegobble)
,则无需使用--vanilla
.
In your case if your .Rprofile had if (interactive()) library(hobblegobble)
you wouldn't need to use --vanilla
.
这篇关于在R CMD构建中使用--vanilla的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!