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

29,934

Solution 1

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.

Solution 2

Also this solution from the Rstudio blog

require(devtools)
install_version("ggplot2", version = "0.9.1", repos = "http://cran.us.r-project.org")

https://support.rstudio.com/hc/en-us/articles/219949047-Installing-older-versions-of-packages

Solution 3

If using Rstudio, select "install from Package Archive File(.zip;.tar.gz)" in "Install Packages" window.

Solution 4

On linux this is simply:

sudo su - -c "R -e \"devtools::install_url('https://cran.r-project.org/src/contrib/RecordLinkage_0.4-10.tar.gz')\""
Share:
29,934
Rainmaker
Author by

Rainmaker

Updated on July 09, 2022

Comments

  • Rainmaker
    Rainmaker almost 2 years

    I typed the following in the R command line:

    install.packages("RecordLinkage") 
    

    I got the following error:

    Warning in install.packages :
      package ‘RecordLinkage’ is not available (for R version 3.1.0)
    

    However, one of my coworkers did the exact same thing on the exact same version of R (3.1.0) and it worked. In addition, I've managed to install other packages successfully.

    Any idea why this does not work? Any help would be greatly appreciated.

  • joran
    joran almost 10 years
    The build tools on OS X do require some installation (XCode, and the associated command line tools).
  • Ben Bolker
    Ben Bolker almost 10 years
    if you have the compilation tools you may also be able to use devtools::install_version("RecordLinkage",version="0.4-1") as a shortcut.
  • Rainmaker
    Rainmaker almost 10 years
    Thanks so much for the help everyone! @Andrie I copied and pasted your code into RStudio and it worked perfectly (but I had to download a few other packages that RecordLinkage depends on first).
  • puslet88
    puslet88 over 8 years
    See also stackoverflow.com/questions/18655976/… for a one-lin answer similar to Ben Bolker's.
  • Aurèle
    Aurèle over 6 years
    May I suggest https instead of http? (maybe it wasn't available at the time of this answer, now it is)