我知道你可以使用以下语法从 CRAN 安装软件包:
install.packages(c("Rcpp"), dependencies=TRUE)
您可以使用以下命令从 CRAN 更新所有内容:
update.packages()
另一方面,您可以使用以下命令从 GitHub 安装包(编译它们):
install_github("hadley/tidyr")
如何升级所有 GitHub 包?
我的意思是无需一次重新安装(和编译)它们。就像是update.packages()
对于 github。
这对我有用。它会遍历库中的所有包,而不仅仅是加载的包。
update_github_pkgs <- function() {
# check/load necessary packages
# devtools package
if (!("package:devtools" %in% search())) {
tryCatch(require(devtools), error = function(x) {warning(x); cat("Cannot load devtools package \n")})
on.exit(detach("package:devtools", unload=TRUE))
}
pkgs <- installed.packages(fields = "RemoteType")
github_pkgs <- pkgs[pkgs[, "RemoteType"] %in% "github", "Package"]
print(github_pkgs)
lapply(github_pkgs, function(pac) {
message("Updating ", pac, " from GitHub...")
repo = packageDescription(pac, fields = "GithubRepo")
username = packageDescription(pac, fields = "GithubUsername")
install_github(repo = paste0(username, "/", repo))
})
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)