-->

Set default CRAN mirror permanent in R

2019-01-13 11:48发布

问题:

How can I set a specific CRAN mirror permanently in R?

I want to set it permanently in my laptop so that when I do install.packages(), it won't ask me again which mirror to choose.

回答1:

You can set repos in your .Rprofile to restore your choice every time you start R

Edit: to be more precise:

Add

options(repos=structure(c(CRAN="YOUR FAVORITE MIRROR")))

to your .Rprofile


Alternatively, you check your Rprofile.site (in the directory /your-R-installation/etc/ , eg R-2.14.0/etc). There you see following lines commented out :

# set a CRAN mirror
# local({r <- getOption("repos")
#       r["CRAN"] <- "http://my.local.cran"
#       options(repos=r)})

So remove the comment marks and change "http://my.local.cran" to the correct website.



标签: r cran r-faq