How to select a CRAN mirror in R How to select a CRAN mirror in R r r

How to select a CRAN mirror in R


You should either get a window with a list of repositories or a text menu with some options. But if that is not appearing, you can always specify the mirror from where to download the packages yourself by using repos parameter. By doing that, R will not ask you anymore about the repository. Example:

install.packages('RMySQL', repos='http://cran.us.r-project.org')

Here you have a list of mirrors for R.


Here is what I do, which is basically straight from the example(Startup) page:

## Default repolocal({r <- getOption("repos")       r["CRAN"] <- "http://cran.r-project.org"        options(repos=r)})

which is in ~/.Rprofile.

Edit: As it is now 2018, we can add that for the last few years the URL "https://cloud.r-project.org" has been preferable as it reflects a) https access and b) an "always-near-you" CDN.


I'm a fan of:

chooseCRANmirror()

Which will print the list of mirrors in the output (no worrying a popup window since you are running it from the terminal) and then you enter the number you want.