How to install a CRAN package that has been archived

Sometimes you may come to install a copy of one of your favourite R libraries from CRAN, only to be confronted with the nightmare scenario of it no longer being available.

If you try and install the package in the conventional install.packages() way then you’ll get the error “package is not available for this version of R”. Confusingly, this is the same error message as you get if you misspell the name of the library, so first check you didn’t do that before proceeding.

In the case that the package really has been discontinued from CRAN, the CRAN website displays a message like this, detailing why it’s gone.

CRAN message informing user an R package is no longer on CRAN

Now of course there may be good and important reasons why it’s no longer available, so it’s worth exploring any links on the subject it gives you – the “check results archive” in the case of the above package.

But if you’re confident that you want to, then you can still install the last available version easily enough – point-and-click easy if you’re an RStudio user.

  1. Click on the archive link in the equivalent of the screenshot above.
  2. Download the version of the library you want – typically the newest one. Note that they download as .tar.gz files. Remember where you saved it.
  3. If you haven’t already done so in the past and are using Windows then you’ll need to install RTools. That’s available here. Note that there’s a new version for R version 4.2 and beyond. If you don’t use Windows, you don’t need to do this I believe.
  4. Once you’ve installed RTools, open up RStudio and go to the Tools menu, then “Install packages…”. This is the equivalent of running the command install.packages("path_and_filename_of_your_download.tar.gz", repos = NULL, type = "source") if you prefer the command line, in which case you can ignore the below steps.
  5. Change the “Install from” dropdown to read “Package archive file” and point it towards the file you downloaded in step 2.
RStudio’s install packages dialogue box
  1. Hit the “Install” button and it should go ahead compile and install the library, ready for use in the usual way.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s