How to Install Old Version R Packages in R
Why Install Old Version Packages
To leverage the efficiency improvements and bug fixes of R version updates, I upgraded R on my server to the latest version (currently 4.1). However, when using some packages, I encountered errors like:
Warning message:
“package ‘clusterProfiler’ is not available for this version of R
or
Warning message:
“package ‘EnrichmentBrowser’ is not available for this version of R
Warning message:
“package ‘qvalue’ is not available for this version of R
These errors occur because clusterProfiler
, EnrichmentBrowser
, or qvalue
have not kept pace with R’s updates. If you need to use them on a newer version, you must use special installation methods.
Install from Source
Most of the time, this is the most stable method. Although direct installation via R commands isn’t possible, you can install by downloading the source code. For example, qvalue
:
- First, download the installation package.
Find the download link for the
qvalue
installation package on bioconductor at qvalue and download it:wget [https://bioconductor.org/packages/release/bioc/src/contrib/qvalue_2.26.0.tar.gz](https://bioconductor.org/packages/release/bioc/src/contrib/qvalue_2.26.0.tar.gz)
- Install
Call R’s installation command directly in the shell:
If successful, you’ll see a correct installation prompt:
R CMD INSTALL qvalue_2.26.0.tar.gz
* installing to library ‘/home/teng/R/x86_64-pc-linux-gnu-library/4.1’ * installing *source* package ‘qvalue’ ... ** using staged installation ** R ** data ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (qvalue)
qvalue
is successfully installed.
Similarly, you can install other dependencies one by one.
Finally, clusterProfiler
is installed:
R CMD INSTALL clusterProfiler_4.2.2.tar.gz
* installing to library ‘/home/teng/R/x86_64-pc-linux-gnu-library/4.1’
* installing *source* package ‘clusterProfiler’ ...
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (clusterProfiler)
Summary
This article describes how to install various packages on the latest version of R. Unlike Python, R’s installation method requires many dependencies for the latest version. This time, I downloaded dozens of source codes and installed them one by one. If you don’t want to go through this hassle, it’s better to stick with older R versions. R 3.5 and 3.6 are currently the most convenient for installing various packages, and I recommend using them.
- 原文作者:春江暮客
- 原文链接:https://www.bobobk.com/en/326.html
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。