Installing older version of a package
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In many situations when you install a new package, R will ask you whether you want to update to the updated versions of existing packages in your library. However, the main problem is sometimes in the updated version, a certain function might have been completely removed and thus could mess up your pre-existing code in use.
In this post, I will show how to install an old version of any package as long as it remains on CRAN.
First of all, I will demonstrate the issue with a package called “emmeans”. The package contains different functions for mean multiple comparisons. To date, the latest version of this package is 1.5.3 and was published on 9-Dec-2020. In the new version, CLD() function was removed. The authors/maintainer replaced it with a cld() from multcomp package. Although nothing major changed but for the objective of this post I will assume that we have to use the old CLD() with no alternative found.
Assuming you have already updated the emmeans package on your machine, the first thing to do is to competelely remove the current (most recent) package.
remove.packages("emmeans")
To install a specific version of a package, we need to install a package called “remotes” and then load it from the library. Afterwards we can use install_version() by specifying the package name and version needed as shown below.
install.packages("remotes") library(remotes) install_version("emmeans", "1.4.5")
It is worth noting that the missing function from the updated version is likely replaced by either a new function by the authors/maintainer or they have provided an alternative and documented it in the latest version.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.