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.
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.
- Click on the
archivelink in the equivalent of the screenshot above.
- 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.
- 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.
- 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.
- Change the “Install from” dropdown to read “Package archive file” and point it towards the file you downloaded in step 2.
- Hit the “Install” button and it should go ahead compile and install the library, ready for use in the usual way.