批量运行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)

posted @ 2016-11-17 16:47  Little_Rookie  阅读(848)  评论(0编辑  收藏  举报