I am on macOS and use R from the terminal. R often launches XQuartz, for example with install.packages("digest")
:
> install.packages("digest")
Installing package into ‘~/Library/R/3.5/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
and an XQuartz window opens with Secure CRAN mirrors
.
Another example is when a newer package is available and an XQuartz window opens with
These packages have more recent versions available. Which would you like to update?
digest (0.6.18 -> 0.6.19) [CRAN]
How can I force R to ask the question from the terminal instead of opening XQuartz?
That's because XQuartz is required for MacOSX. In R MacOSX FAQ:
The quartz() device is the native graphic device in R for Mac OS X. ... The quartz() device can be used from R.APP or a suitable build of R running at the Mac console. Where supported it is the default graphics device. ... The quartz device allows for interaction.
One option could be set your CRAN repository when installing packages:
install.packages("digest", repos = "https://cran.r-project.org")
You can also define your CRAN repository in the beginning of your code with options
:
options(repos = structure(c(CRAN = "your_cran_mirror")))
Here's a list of CRAN mirros where you can pick one that best suits for your case.
You can also set these preferences site-wide on the Rprofile.site
, which on macOS is at /Library/Frameworks/R.framework/Resources/etc/Rprofile.site
, with:
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.r-project.org"
options(repos=r)})
P.S.: The later copied from this post.