R报错:WARNING: Rtools is required to build R packages, but is not currently installed.

今天在安装ComplexHeatmap时使用如下命令出现报错:

>install.packages("ComplexHeatmap", type = "source")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
将程序包安装入‘C:/Users/86150/AppData/Local/R/win-library/4.3’
(因为‘lib’没有被指定)
Warning in install.packages :
  package ‘ComplexHeatmap’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

这是因为没有安装rtool所以才会报错。

解决方法:下载安装对应版本的Rtools

1、下载对应版本的Rtools

查看自己安装的R版本---Rtools

> R.version.string
[1] "R version 4.3.2 (2023-10-31 ucrt)"

这里显示自己的安装的版本R是R4.3.2

RTools: Toolchains for building R and R packages from source on Windows

2.按照指示进行安装

3. BiocManage安装ComplexHeatmap
当我在使用install.packages()安装ComplexHeatmap出现了该包对于我的R版本(4.3.1)不可用,如下:

Warning in install.packages : package ‘ComplexHeatmap’ is not available for this version of R A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages


尝试换源无果后,便想到使用BiocManager来安装ComplexHeatmap,由于是新电脑所以需要安装它,安装成功之后可以使用检查版本的命令来确认是否安装成功,运行后会输出其对应的版本。

# install command
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
# check command
BiocManager::version()

安装成功之后,便使用BiocManager的install功能,::两个冒号是R语言中调用指定包下功能时引导符,类似于python中.方法。运行下面的代码,开始安装ComplexHeatmap包。

BiocManager::install("ComplexHeatmap")

在安装过程中出现了有些包需要更新的情况,向你询问update all/some/none ,建议全部更新。如果使用BiocManager::install("ComplexHeatmap")安装出现版本不符的情况可以运行下面的代码强制安装。

BiocManager::install("ComplexHeatmap", force=TRUE)

当包安装成功之后使用library(ComplexHeatmap),提示缺少S4Vector依赖包,按照之前介绍的解决方法,使用install.packages()安装缺少的依赖包即可,但是当我使用intall.packages('S4vector')安装时又出现了版本冲突的问题。

于是便尝试了再次使用BiocManager去安装对应的依赖包,成功解决。

BiocManager::install("S4Vector")

参考来源:

R中高效安装包,以ComplexHeatmap包为例_complexheatmap怎么安装-优快云博客

R报错:WARNING: Rtools is required to build R packages, but is not currently installed._warning: rtools is required to build r packages bu-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值