在使用R语言完成数据分析的过程中,很多时候,因为项目实际需要,我们应该指定某些库文件的安装包的版本,这个时候,我们可以基于devtools
包中的函数install_version
来完成。
这里,我们以安装库文件ggplot2
的安装包的版本号为3.3.6为例来说明,即
devtools::install_version("ggplot2",version = "3.3.6",repos = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/")
说明如下:
- version
版本号
- repos
仓库地址,这里将其指定为清华大学开源镜像站的地址文章来源:https://www.toymoban.com/news/detail-832985.html
devtools::install_version("ggplot2",version = "3.3.6",repos = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/")
Downloading package from url: https://mirrors.tuna.tsinghua.edu.cn/CRAN//src/contrib/Archive/ggplot2/ggplot2_3.3.6.tar.gz
Installing package into ‘/home/lwk/R/x86_64-pc-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)
* installing *source* package ‘ggplot2’ ...
** package ‘ggplot2’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** 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 (ggplot2)
参考文献文章来源地址https://www.toymoban.com/news/detail-832985.html
- Installing older versions of packages
- R 3.2.3 devtools::install_version() fails (.zip file not found)
到了这里,关于How to install a specific version of a package in R的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!