批量运行R包

#批量运行包:
all.pcg <- c("data.table","ggplot2","rmarkdown","tidyr","stringr","ggfortify")
sapply(all.pcg, library, character.only = T)
req.pcg <- function(pcg){
new <- pcg[!(pcg %in% installed.packages()[, "Package"])]
if (length(new)) install.packages(new, dependencies = T)
sapply(pcg, require, ch = T)
}
req.pcg(all.pcg)

原文地址:https://www.cnblogs.com/nxld/p/6074431.html