从GitHub更新所有软件包 [英] Update all packages from GitHub
问题描述
我知道您可以使用以下语法从CRAN安装软件包:
I know you can install packages from CRAN with this syntax:
install.packages(c("Rcpp"), dependencies=TRUE)
您可以使用以下命令从CRAN更新所有文件:
You can update all of them from CRAN with:
update.packages()
另一方面,您可以使用以下方法从GitHub安装软件包(编译它们):
On the other side, you can install packages (compiling them) from GitHub with:
install_github("hadley/tidyr")
如何升级所有GitHub软件包?
How can you upgrade all GitHub packages?
我的意思是无需一次重新安装(和编译)它们.像update.packages()
那样的github.
I mean without reinstalling (and compiling) them one at a time. Something like update.packages()
for github.
推荐答案
library(devtools)
#' Update all github installed packages.
#'
#' This will trash any non-master branch installs, and spend time re-installing
#' packages which are already up-to-date.
update_github <- function() {
pkgs = loadedNamespaces()
print(pkgs)
desc <- lapply(pkgs, packageDescription, lib.loc = NULL)
for (d in desc) {
message("working on ", d$Package)
if (!is.null(d$GithubSHA1)) {
message("Github found")
install_github(repo = d$GithubRepo, username = d$GithubUsername)
}
}
}
# test it:
# install github version of tidyr
install_github("hadley/tidyr")
library(tidyr)
update_github()
如果您安装的github安装比user/repo的master分支更复杂,请不要运行它.如果您有很多github安装,也要小心,因为这会盲目地将它们全部重新安装,即使是最新的.这可能会花费很长时间,并且如果github master分支没有处于最佳状态,也可能会破坏工作包.
Don't run this if you have any github installations from anything more complicated than the master branch of user/repo. Also be careful if you have a lot of github installations, since this will blindly reinstall them all, even if up-to-date. This could take a long time, and also might break working packages if github master branches are not in tip top condition.
有关详细信息,请查看devtools R/session_info.r
.
Take a look at devtools R/session_info.r
for details.
这篇关于从GitHub更新所有软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!