想写一个批量安装R包的代码
最好的办法就自己diy一个function:
packages=c("tidyverse","data.table","devtools","shiny","shinydashboard",
"sommer","agridat","agricolae","desplot")#准备安装的R包的清单。
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}#定义function
ipak(packages)#批量安装
转自:https://zhuanlan.zhihu.com/p/61887564