Menu Home

R Tip: Check What Repos You are Using

In a lot of our R writing we casually say “install from CRAN using install.packages('PKGNAME')” or “update your packages by using update.packages(ask = FALSE, checkBuilt = TRUE) (and answering ‘no’ to all questions about compiling).”

We recently became aware that for some users this isn’t complete advice.

The above depends on your R install pointing to a repository that is in fact up to date. To check what repositories you are using please use the command options('repos').

For my R installation this looks like the following.

> options('repos')

I am using a CRAN mirror at “”. This is a mirror supplied by RStudio Inc., and tends to be up to date.

What I have recently heard from some readers of Practical Data Science with R that the above commands are not in fact updating to new packages, but instead picking up packages from Aug 01, 2018. This happens to Microsoft R Open users, as by default Microsoft R Open locks to a repository that is fixed at the release date of the given version of Microsoft R Open. From the FAQ:

Why can’t I update to or install the latest CRAN packages?


    By default, Microsoft R Open offers its users predictability using a static CRAN snapshot date. For example, the CRAN repository for Microsoft R Open 3.5.3 is configured to point to a snapshot date of Apr 15, 2019. Consequently, with Microsoft R Open 3.5.3 you’ll always get packages as they were at midnight UTC on Apr 15, 2019 by default whenever you use install.packages.

    Using a fixed CRAN repository snapshot means that every user of Microsoft R Open has access to the same set of CRAN package versions. This makes sharing R code that relies on R packages easier, and reduces the chance of incompatible R packages being installed on the same system. Learn more about fixed CRAN repository snapshots.

    It is possible to change the default repository date.

A user of the current version of Microsoft R Open 3.5.3 is, by default, stuck at April 15, 2019 packages. And, as an additionao example: a user of Microsoft R Open 3.5.1 is, by default, stuck at August 01, 2018 packages.

Our advice is: check your mirror with options('repos'), and if you are using a repository mirror that is not suited to your needs, consider changing it (the Microsoft FAQ has instructions). However, this is going to be a problem when CRAN moves to a post-3.6.* version of R. As CRAN only provides binaries for one version of R prior to the current one. So when CRAN moves to post-3.6.* R most non version-stuck mirrors will not have 3.5.* binary versions of packages.

Unless you have an important production reason for sticking with an older version of R, or older packages: we suggest upgrading and testing your installation (especially if you are starting new work).

Categories: Tutorials

Tagged as:


Data Scientist and trainer at Win Vector LLC. One of the authors of Practical Data Science with R.