• Welcome to LiuJason's Blog!

R语言安装所有扩展包 Install All Packages in CRAN

R语言 Jason 6 years ago (2019-03-29) 1250 Views 0 Comments QR code of this page
方案1:获取已安装列表,把CRAN上的包去掉列表然后全部安装
# get names of installed packages
packs <- installed.packages()
exc <- names(packs[,'Package'])
# get available package names
av <- names(available.packages()[,1])
# create loooong string
ins <- av[!av %in% exc]
install.packages(ins)

方案2:同上
availablePackages=available.packages()
availablePackages<-as.vector(availablePackages[,1])
installedPackages=.packages(all.available = TRUE)
missedPackages<-setdiff(availablePackages, installedPackages)
for (i in 1:length(missedPackages))
{
pkgName <- missedPackages[i]
install.packages(pkgName)
}
print("END")

This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/249.html
Like (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址