R – changing mirror in RStudio

CRAN (The Comprehensive R Archive Network) is a distributed set of servers that allow people to download the various R packages from a bunch of servers that are all “mirrors” of each other. These servers or mirrors are called “repositories.” There are many advantages to this: (1) people can download from a mirror that is closer to them which should result in a faster download and (2) if a server or mirror goes down, you can switch to one that is still up.

If you ever find yourself in the situation that you are unable to update a package because CRAN is down, there is a quick and easy way to change the server you use for downloading packages.

In RStudio, click on Tools -> Global Options:

In the window that comes up, look for “Packages” on the left hand side:

To change the repository, click on “Change” and select a different location:

When you’re done, select “OK” and “OK” again. You can then try updating your packages or downloading new packages again. Assuming that mirror is up and running, that should solve your problem.

 270 total views,  2 views today