Created
December 8, 2012 13:14
-
-
Save jjallaire/4240240 to your computer and use it in GitHub Desktop.
loaded package requires update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loadedPackageRequiresUpdate <- function(pkgs) { | |
| if (any(pkgs %in% loadedNamespaces())) { | |
| return(TRUE) | |
| } | |
| else { | |
| # compute dependent packages | |
| avail <- available.packages() | |
| if (getRversion() >= "2.15") | |
| deps <- tools:::package_dependencies(pkgs, db = avail, recursive = TRUE) | |
| else | |
| deps <- tools:::.package_dependencies(pkgs, db = avail, recursive = TRUE) | |
| deps <- unique(as.character(c(deps, recursive=TRUE))) | |
| # exclude built in R packages (e.g. tools, utils, methods) | |
| deps <- intersect(deps, row.names(avail)) | |
| # check whether a loaded package will be updated | |
| loadedDeps <- intersect(deps, loadedNamespaces()) | |
| return(length(loadedDeps) > 0) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment