How to Install a Package That Has Been Archived from Cran

How do I install a package that has been archived from CRAN?

The package has been archived, so you will have to install from an archive.

I know this because the package home page at http://cran.r-project.org/web/packages/RecordLinkage/index.html tells me:

Package ‘RecordLinkage’ was removed from the CRAN repository.

Formerly available versions can be obtained from the archive.

Archived on 2015-05-31 as memory access errors were not corrected.

By following the link to archives (http://cran.r-project.org/src/contrib/Archive/RecordLinkage) I get a list of all old versions:

[   ]   RecordLinkage_0.3-5.tar.gz  12-Sep-2011 18:04   688K     
[ ] RecordLinkage_0.4-1.tar.gz 12-Jan-2012 09:39 676K

So now I know the version number of the most recent version. The way forward is to download the tarball, install all package dependencies and then install the package from the local downloaded file.

Try this:

# Download package tarball from CRAN archive

url <- "http://cran.r-project.org/src/contrib/Archive/RecordLinkage/RecordLinkage_0.4-1.tar.gz"
pkgFile <- "RecordLinkage_0.4-1.tar.gz"
download.file(url = url, destfile = pkgFile)

# Expand the zip file using whatever system functions are preferred

# look at the DESCRIPTION file in the expanded package directory

# Install dependencies list in the DESCRIPTION file

install.packages(c("ada", "ipred", "evd"))

# Install package
install.packages(pkgs=pkgFile, type="source", repos=NULL)

# Delete package tarball
unlink(pkgFile)

Note:

This will only work if you have the build tools installed on your machine. On Linux this will be the case. But on Windows you will have to install RTools if you don't have it already. And on OS X (Mac) you will have to install XCode and the associated command line tools.

How do I install an archived CRAN package

To see if a package has been archived, you can go to its CRAN page. In this case, it is https://cran.r-project.org/web/packages/allanvar , but it's the same url pattern for other packages. Just put the package name after the last forward slash.

You will see on this page that it has been archived since 2020. To get the last stable CRAN version (which passed all CRAN checks with R version 4.0.2), you can do:

devtools::install_version('allanvar', version = '1.1')

installing an archived package

This is an old (archived) package that is no longer supported. If you really need it, you can install it using R CMD INSTALL but you need also to install all its dependencies manually.

Installing your desired package gave me the following:

>R CMD INSTALL ~/Downloads/rlandscape_1.0.tar.gz 
* installing to library ‘/Users/mohamedahmed/Rlibs’
ERROR: dependencies ‘spatstat’, ‘deldir’, ‘gWidgets’, ‘gWidgetsRGtk2’ are not available for package ‘rlandscape’
* removing ‘/Users/mohamedahmed/Rlibs/rlandscape’

I am not sure all dependencies are still available on CRAN, but it seems to be challenging task.

Install R packages in archive

You can try the function install_version in devtools. Let us suppose you want to install version 0.8 of ggplot2, you can call it as install_version('ggplot2', '0.8'). If you are on Windows, you can follow the instructions here to build packages from source.

Installing a Package Removed from CRAN

Besides installing from the CRAN mirror repo, another option is

remotes::install_version("DMwR", version="0.4.1")
  • for this method, you do have to look up the last version in the archive directory (would probably be scrapeable if you wanted to write the code)
  • as with remotes::install_github("cran/<package>"), you will be installing from source, which means that if the package or any of its dependencies have compiled components (in this case it doesn't appear so), you'll need to have development tools (compiler etc.) installed on your system

A quick word of caution:

  • this will work well if packages have been archived recently, and if the reason for archiving was because the CRAN maintainers are being fussy (that's their prerogative);
  • however, a package may have become incompatible with the rest of the current R ecosystem (R version, dependencies) since its last update - in which case you may find yourself in dependency hell trying to install it (or, worse, your results may be unreliable).

How to build an archived package on R 3.0.0

The easiest way to build a package from the archive is to use devtools:

library(devtools)
install_url("http://cran.r-project.org/src/contrib/Archive/uroot/uroot_1.4.tar.gz")

There are three challenges:

  • You need to have a working development environment. On windows, this means you need Rtools; on the mac, the xcode command line tools; and on linux, the appropriate development packages

  • There is currently a bug in devtools which means it doesn't find the right version of Rtools on windows. A fix is on its way to CRAN.

  • There's normally a good reason that a package has been put in the archive: it's likely that it does not pass R CMD check in the current version of R, so even once you've installed it, it might not work correctly. Be careful!



Related Topics



Leave a reply



Submit