How to Use CRAN to Find R Code and Packages

The Comprehensive R Archive Network CRAN is a network of web servers around the world where you can find the R source code, R manuals and documentation, and contributed packages.

CRAN isn’t a single website; it’s a collection of web servers, each with an identical copy of all the information on CRAN. Thus, each web server is called a mirror. The idea is that you choose the mirror that is located nearest to where you are, which reduces international or long-distance Internet traffic. You can find a list of CRAN mirrors at CRAN mirrors

RGui and RStudio allow you to set the location of your nearest CRAN mirror directly in the application. For example, in the Windows RGui, you can find this option by choosing Packages→Set CRAN mirror. In RStudio, you can find this option by choosing Tools→Options→R→CRAN mirror.

Regardless of which R editor you use, you can permanently save your preferred CRAN mirror (and other settings) in special file called .RProfile, located in the user’s home directory or the R startup directory. For example, to set the Imperial College, UK mirror as your default CRAN mirror, include this line in your .RProfile:

options("repos" = c(CRAN = ""))

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.