我们周末班准备工作给的安装R包 http://www.bio-info-trainee.com/3727.html
首先配置中国大陆特色镜像
options()$repos
options()$BioC_mirror
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options()$repos
options()$BioC_mirror
然后按需安装指定的R包
# https://bioconductor.org/packages/release/bioc/html/GEOquery.html
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("KEGG.db",ask = F,update = F)
BiocManager::install(c("GSEABase","GSVA","clusterProfiler" ),ask = F,update = F)
BiocManager::install(c("GEOquery","limma","impute" ),ask = F,update = F)
BiocManager::install(c("org.Hs.eg.db","hgu133plus2.db" ),ask = F,update = F)
实际上,大家即使是没有学习过R包安装,也可以看得懂,变化R包名字,就可以一行行运行代码来安装指定的包了!
批量安装R包而且不重复安装呢?
当然也是有办法的, 我在移植一些shiny应用程序就用到过。
list.of.packages <- c("shiny",
"tidyr",
'tidyverse',
"clusterProfiler",
"DT",
"ashr",
"enrichplot",
"plotly")
#checking missing packages from list
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
new.packages
packToInst <- setdiff(list.of.packages, installed.packages())
packToInst
if(T){
lapply(packToInst, function(x){
BiocManager::install(x,ask = F,update = F)
})
}
lapply(intersect(packagesReq, installed.packages()),function(x){
suppressPackageStartupMessages(library(x,character.only = T))
})
其实你有没有发现,代码反而是多了呢?
嘻嘻