安裝R語言包的時候,經(jīng)常出現(xiàn):package 'xxx' is not available (for R version x.y.z)校辩,搞得人心煩意亂,安裝一個軟件要個把小時,坑爹俺惨簟激才?
到底要怎么解決這個問題呢拓型?一般有一下思路:
低級錯誤
檢查拼寫是否正確?注意大小寫
其實已經(jīng)安裝好了瘸恼,退出R再試一次
- 如果出現(xiàn)錯誤
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")
需要安裝相應(yīng)編譯器
- 如
* 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’時退出狀態(tài)的值不是0
- 如果出現(xiàn)上面的錯誤东帅,就安裝好geos-devel就可以了
yum install -y geos-devel
沒有源碼压固,但是有binary文件
- 可以把源碼安裝關(guān)了
options(install.packages.check.source = "no")
找錯地方了
找對repository
- 有的包不在CRAN里面
安裝bioconductor的包,必須
source("https://bioconductor.org/biocLite.R")
否則可能報錯:
ERROR: compilation failed for package
- 設(shè)置repository的方法
setRepositories()
- 查看你要的package在不在這個repository里面靠闭,以“foobarbaz”為例
ap <- available.packages()
"foobarbaz" %in% rownames(ap)
包在github等網(wǎng)站上面
- 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