介绍
available.packages()
函数提供当前CRAN的R包列表
packages <-c("tidyverse", "limma","ggplot2", "pheatmap")
#检查所需的R包是否已安装,若未安装则从CRAN或Bioconductor安装包
packagecheck <- function(x) {
if (!require("BiocManager")) {
install.packages("BiocManager")
} else if (!require(x, character.only = T)) {
CRANpackages <- available.packages()
if (x %in% rownames(CRANpackages)) {
install.packages(x)
} else {
BiocManager::install(x, update = TRUE, ask = FALSE)
}
}
}
lapply(packages, packagecheck)
网友评论