加载包:

2021-03-21  本文已影响0人  哇珍

当包不能安装时

第一类情况

第一种方法

install.packages("remotes")
remotes::install_github("包名'')

第二种方法

if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("包名")

第三种方法

library(utils)
rforge <-  "http://r-forge.r-project.org"
install.packages("包名", repos=rforge, dependencies=TRUE)

第四种方法(我比较常用)

install.packages("包名",repos = "https://mirrors.tuna.tsinghua.edu.cn/CRAN")

第五种方法(成功率99%)

install.packages('package-name',repos='http://cran.us.r-project.org')

第二类情况

当显示R版本太低

Warning in install.packages :package ‘caTools’ is not available (for R version 3.4.4)

Check that getOption("repos") refers to a CRAN repository that contains the needed package versions:

packageurl <- https://cran.r project.org/src/contrib/Archive/caTools/caTools_1.14.tar.gz  
install.packages(packageurl, repos=NULL, type="source")

下载了包之后不能运行

library(DESeq2)

Loading required package: SummarizedExperiment
Loading required package: DelayedArray
Loading required package: matrixStats
Error in value[3L] :
Package ‘matrixStats’ version 0.57.0 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘matrixStats’ is imported by ‘coin’ so cannot be unloaded

处理:

install.packages("matrixStats",dependencies = TRUE, repos = "http://cran.us.r-project.org")
上一篇下一篇

猜你喜欢

热点阅读