问题
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".
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
thanks
回答1:
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).
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.
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.
In your case if your .Rprofile had if (interactive()) library(hobblegobble) you wouldn't need to use --vanilla.
来源:https://stackoverflow.com/questions/11638147/using-vanilla-with-r-cmd-build