安装R语言包的时候,经常出现:package ‘xxx’ is not available (for R version x.y.z),搞得人心烦意乱,安装一个软件要个把小时,坑爹啊?
到底要怎么解决这个问题呢?一般有一下思路:
低级错误
检查拼写是否正确?注意大小写
其实已经安装好了,退出R再试一次
- 如果出现错误
Encountered below error. Any suggestions on how to resolve appreciated.
shiny::runApp()
Error in get(Info[i, 1], envir = env) : lazy-load database 'XX' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
其实只要退出R,再试一次就可以了:The internal error -3
often happens when you use install_github to install a package that’s currently loaded; try restarting R and running the app again.
安装方式
源码安装
- 没有windows/mac/linux的binary文件,可以用源码安装:
install.packages("foobarbaz",type="source")
需要安装相应编译器
- 如
* installing *source* package ‘rgeos’ ...
configure: CC: gcc -m64 -std=gnu99
configure: CXX: g++ -m64
configure: rgeos: 0.4-2
checking for /usr/bin/svnversion... yes
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision:
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/shiyong/R/x86_64-redhat-linux-gnu-library/3.5/rgeos’
下载的程序包在
‘/tmp/RtmpUwOGCq/downloaded_packages’里
Warning message:
In install.packages("rgeos", repos = "http://R-Forge.R-project.org", :
安装程序包‘rgeos’时退出狀態的值不是0
- 如果出现上面的错误,就安装好geos-devel就可以了
yum install -y geos-devel
没有源码,但是有binary文件
- 可以把源码安装关了
options(install.packages.check.source = "no")
找错地方了
找对repository
- 有的包不在CRAN里面
安装bioconductor的包,必须
source("https://bioconductor.org/biocLite.R")
否则可能报错:
ERROR: compilation failed for package
- 设置repository的方法
setRepositories()
- 查看你要的package在不在这个repository里面,以“foobarbaz”为例
ap <- available.packages()
"foobarbaz" %in% rownames(ap)
包在github等网站上面
- package在github/Bitbucket/Gitorious上面
library(remotes)
install_github("packageauthor/foobarbaz")
install_github("cran/foobarbaz")
install_bitbucket("packageauthor/foobarbaz")
install_gitorious("packageauthor/foobarbaz")
package在一个非标准的repository里,而不是CRAN
install.packages("Rbbg", repos = "http://r.findata.org")
版本问题
需要更新R或Bioconductor了
- 查看依赖的版本
ap["foobarbaz","Depends"]
package过期了
library(remotes)
install_version("foobarbaz","0.1.2")
最后大招
用conda安装,如
conda install bioconductor-deseq2
手动安装:
install.packages("local.tar.gz",repos=NULL, type="source")
安装好依赖包
install.packages("ggplot2",dependencies=T)
放弃
- 想想,是不是不需要这个package也可以解决问题?
Changelog:
- 作者:石勇(sandy,石博士)
- 时间:20181030
- 参考:stackoverflow