参考:
解决Package is not available (for R version XXX)? - Bioinfarmer - 博客园 (cnblogs.com)
安装历史版本的R包 - 简书 (jianshu.com)
总结版:
- 无ComplexHeatmap包
- 又提示无GetoptLong包
- 无rjson包(R版本过低<3.6>,最新rjson仅支持R≥4.0)
#①devtools指定版本安装
require(devtools)
install_version("rjson", version = "0.2.20", repos = "http://cran.us.r-project.org")
#②用源代码安装
packageurl <- "https://cran.r-project.org/src/contrib/Archive/rjson/rjson_0.2.20.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
接着再转头安装GetoptLong
install.packages("GetoptLong")
#再安装ComplexHeatmap
install_github("jokergoo/ComplexHeatmap")
- 无updog、viridis包
install.packages("updog")
install.packages("viridis")
再去安装binmapr
devtools::install_github("xuzhougeng/binmapr")
啰嗦版:
刚解决了devtools无法安装,又出现了通过它安装binmapr包的问题
首先来看看报错
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘ComplexHeatmap’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package ‘binmapr’
* removing ‘/data/kesimin/R/x86_64-pc-linux-gnu-library/3.6/binmapr’
Warning message:
In i.p(...) :
installation of package ‘/tmp/RtmpxzWeiv/file7be4b54b4ca1c/binmapr_0.2.tar.gz’ had non-zero exit status
可以看到显示说没有ComplexHeatmap这个包,那就试试去安装ComplexHeatmap包
install.packages("ComplexHeatmap")
#又出现报错
Installing package into ‘/data/kesimin/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘ComplexHeatmap’ is not available (for R version 3.6.3)
这应该是说我的R版本太低了,不支持这个包555
于是我就去找了这个吧的官方文档
ComplexHeatmap Complete Reference (jokergoo.github.io)
上面推荐的安装方式是用devtools安装
library(devtools)
install_github("jokergoo/ComplexHeatmap")
安装过程中提示我需要update
Downloading GitHub repo jokergoo/ComplexHeatmap@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: digest (0.6.27 -> 0.6.29) [CRAN]
#根据提示,输入1
Enter one or more numbers, or an empty line to skip updates: 1
updates
等啊等,发现继续报错
Installing package into ‘/data/xxx/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
ERROR: dependency ‘GetoptLong’ is not available for package ‘ComplexHeatmap’
* removing ‘/data/kesimin/R/x86_64-pc-linux-gnu-library/3.6/ComplexHeatmap’
Warning messages:
1: package ‘rjson’ is not available (for R version 3.6.3)
2: In i.p(...) :
installation of package ‘GetoptLong’ had non-zero exit status
3: In i.p(...) :
installation of package ‘/tmp/RtmpxzWeiv/file7be4b4932f0d2/ComplexHeatmap_2.11.2.tar.gz’ had non-zero exit status
我们现在需要下载的是GetoptLong这个包
install.packages("GetoptLong")
#继续报错,需要rjson包
Installing package into ‘/data/kesimin/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘rjson’ is not available
trying URL 'https://cloud.r-project.org/src/contrib/GetoptLong_1.0.5.tar.gz'
Content type 'application/x-gzip' length 767681 bytes (749 KB)
==================================================
downloaded 749 KB
ERROR: dependency ‘rjson’ is not available for package ‘GetoptLong’
* removing ‘/data/kesimin/R/x86_64-pc-linux-gnu-library/3.6/GetoptLong’
Warning in install.packages :
installation of package ‘GetoptLong’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpxzWeiv/downloaded_packages’
由于直接install.packages的话,会提示不支持R 3.6版本,最新的rjson仅支持R≥4.0
在R-CRAN上查看历史版本
Index of /src/contrib/Archive/rjson (r-project.org)
rjson-history
指定版本下载R包有两种方法
①用devtools
require(devtools)
install_version("rjson", version = "0.2.20", repos = "http://cran.us.r-project.org")
但是这个方法并不能保证所有情况适用
②源代码安装
a.Rstudio操作
#linux上下载相应版本的rjson包文件
wget https://cran.r-project.org/src/contrib/Archive/rjson/rjson_0.2.20.tar.gz
Rstudio-server上,tools→install packages→Browse,选择下载的文件→install
源代码安装
b.命令行操作
packageurl <- "https://cran.r-project.org/src/contrib/Archive/rjson/rjson_0.2.20.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
rjson安装成功,现在是安装GetoptLong
install.packages("GetoptLong")
安装成功!
接着是ComplexHeatMap
install_github("jokergoo/ComplexHeatmap")
安装成功!
devtools::install_github("xuzhougeng/binmapr")
#又报错了
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘updog’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package ‘binmapr’
* removing ‘/xxx/R/x86_64-pc-linux-gnu-library/3.6/binmapr’
Warning message:
In i.p(...) :
installation of package ‘/tmp/RtmpxzWeiv/file7be4b7ca07010/binmapr_0.2.tar.gz’ had non-zero exit status
那我们现在就去安装这个updog包,安装完后又是少了个viridis包
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘viridis’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
啥也别说了,继续install.packages("viridis")安装
最后!终于!把它装好了!
binmapr
网友评论