常见安装方法
1. CRAN仓库直接安装
默认的安装方法,大部分CRAN的包都可以完美安装。
install.packages("包名")
2. 包位置安装
指定压缩包的位置,最常用的方法。常见于Bioconductor包,因为网络问题可能导致无法流畅下载安装,此时可以下载包并使用本地的方式进行安装。
install.packages("包位置", repos = NULL, type = "source")
3. 版本指定安装
使用remotes::install_version()指定包的版本。repos通常是仓库的路径。
remotes::install_version("包名", version = "版本号", repos = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/")
这两个默认的都是装1.6 此方法也同样用于提示R版本不匹配
install.packages('MigClim')
remotes::install_version("MigClim")
这个才是最新版
install.packages("https://cloud.r-project.org/src/contrib/Archive/MigClim/MigClim_1.6.2.tar.gz")
4. Bioconductor管理器安装
使用Bioconductor管理器进行安装。
BiocManager::install("包名")
5. 源码包安装
如果你下载了包的源码(例如通过git clone),可以用如下方式安装。.表示当前已经进入了R包源码目录。
install.packages(".", repos = NULL, type = "source")
6. devtools方式安装
使用devtools包来安装GitHub上的包。
library(devtools)
devtools::install_github("仓库名/项目名", dependencies = TRUE)
补充其他姿势
devtools::install_git("任意git开头的链接")
万能方式: 第3种方法(包位置安装)支持任意位置和任何形式(源码或压缩包)。如果你还没有安装remotes包,可以按如下方式安装并使用:
# 如果你还没有安装 remotes
install.packages("remotes")
library(remotes)
这个格式使用了清晰的标题、列表和代码块,便于快速查找和理解不同的安装方式。 奇怪的包收集
install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE)
install.packages("BAPC", repos="http://R-Forge.R-project.org")
install.packages("fmesher", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"))
install.packages("Epi")
install.packages("fanplot")
问题处理
-
Monocle3 在使用Error: ! `nei()` was deprecated in igraph 2.1.0 and is now defunct. ℹ Please use `.nei()` instead. Run `rlang::last_trace()` to see where the error occurred.orderCells()时,其内部调用的igraph::nei()函数在igraph >= 2.1.0中被废弃(defunct),因此你需要把igraph降级到一个旧版本以解决这个兼容问题。
根据 Monocle3 团队和用户的反馈:
-
报错出现在
igraph2.1.1 中,使用igraph < 2.1.0可以避免这个错误 github.com+1github.com+1rdrr.io+3cole-trapnell-lab.github.io+3github.com+3。 -
通常推荐降级到
igraph2.0.x解决方案
install.packages("https://cran.r-project.org/src/contrib/Archive/igraph/igraph_2.0.3.tar.gz", repos = NULL, type = "source")
remotes::install_github("RajLabMSSM/echolocatoR")
这个包非常诡异 直接把git的免费api刷光了 不得不创建私有key进行安装
在R中 生成token链接 usethis::create_github_token() 提示opening url部分复制到浏览器打开 登录github授权
-
根据需要选择权限,建议选择以下选项:
repo(访问私有仓库)read:org(如果需要访问组织信息)
-
点击 Generate token 生成 Token,并复制保存。 指令设置key
Sys.setenv(GITHUB_PAT ="")