R Tip: Check What Repos You are Using

[This article was first published on R – Win-Vector Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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') $repos CRAN "https://cran.rstudio.com/"

I am using a CRAN mirror at “https://cran.rstudio.com/”. 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).

To leave a comment for the author, please follow the link and comment on their blog: R – Win-Vector Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)