2 Simple Methods to Install an Archived Package in R

Deepanshu Bhalla Add Comment

This tutorial explains the multiple methods to install an archived package in R.

Sometimes, you might need to install an older version of an R package when your R code doesn't function properly with the current version of the package. This situation commonly occurs when you can't communicate with the R package developer to make adjustments that would make it compatible with your own R setup. This issue also arises when another package depends on a previous version of the R package.

Method 1: Install an archived package using devtools

If devtools package is not already installed on your system, you can install it using this command install.packages("devtools").

In the code below, we are using the function install_version to install the archive package named "DWD" package version "0.11".

library(devtools)
install_version("DWD", version = "0.11", repos = "https://cloud.r-project.org")

Method 2: Install an archived package using install.packages

Search the package you want to install in the CRAN Package Archive link. Click on the package and then copy the URL of the file with the tar.gz extension.

In R, you can install an archived package by following the steps below.

  1. Download and Install Rtools: You need to have this tool to build package from source.
    Link - Rtools
  2. Install the Package: You can install the package using the install.packages() function. See the syntax below:
url <- "http://cran.r-project.org/src/contrib/Archive/DWD/DWD_0.11.tar.gz"
install.packages(url, type="source", repos=NULL)
  • Replace http://cran.r-project.org/src/contrib/Archive/DWD/DWD_0.11.tar.gz with the actual path to your downloaded package archive.
  • repos = NULL indicates that you are not using a repository for installation. You are providing the package locally.
  • type = "source" specifies that the package is a source package.

If you are getting this error : "installation of package had non-zero exit status", you can load package using load_all function from devtools package.

devtools::load_all("C:/Users/deepa/Documents/R/win-library/4.1/wdman")

Make sure to use the actual path to your R package.

Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

Post Comment 0 Response to "2 Simple Methods to Install an Archived Package in R"
Next → ← Prev