719016 719016 - 14 days ago 4
R Question

Set default CRAN mirror permanent in R

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

, it won't ask me again which mirror to choose.


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

Edit: to be more precise:


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.