Skip to content

Instantly share code, notes, and snippets.

@zkamvar
Created April 25, 2017 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zkamvar/4c587737aeb1ff35021c89c456f7ceda to your computer and use it in GitHub Desktop.
Save zkamvar/4c587737aeb1ff35021c89c456f7ceda to your computer and use it in GitHub Desktop.
Script for updating CRAN packages
# Note: this assumes that you have a custom library at the top of your .libPaths()
fields <- c("Package", "LibPath", "Version", "Priority", "Depends", "Imports", "LinkingTo", "Suggests", "Enhances", "OS_type", "Built", "RemoteSha", "Packaged", "biocViews")
x <- installed.packages(.libPaths()[1], fields = fields)
needs_update <- x[x[, "Built"] != "3.4.0", ]
bicond <- !is.na(needs_update[, "biocViews"])
ghub <- !is.na(needs_update[, "RemoteSha"])
remote <- !is.na(needs_update[, "Packaged"])
bioconductor <- needs_update[bicond, ]
cran <- needs_update[!bicond & !ghub & remote, ]
install.packages(rownames(cran))
@zkamvar
Copy link
Author

zkamvar commented Apr 25, 2017

Actually, just use

update.packages(ask = FALSE, checkBuilt = TRUE)

https://twitter.com/ucfagls/status/856978295358799873

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment