Greetings.
There's a coalescing group which is working to imitate Dirk's fine translation of CRAN to APT, in the Fedora/Red-Hat flavored land. One of the things we're trying to do is implement as much as is possible in R directly, and use as much of the existing package management infrastructure as we can. To this end, I humbly submit a few small patches to that infrastructure. The first of the two patches below is the more important one; It adds to 'getDependencies' an 'installed' option, defaulting to NULL. This permits us to specify a counterfactual set of "installed packages". With this option in place, we can ask getDependencies "What would someone need, to install this package, if they only had -thus- installed". In practice, -thus-, for us, attempts to be "just the base packages". The second of the two patches is more cosmetic. getDependencies is quite verbose about what it's doing, and it would be nice to be able to mask the merely informative messages. The patch adds a 'verbose' option, defaulting to TRUE. This permits us to turn off the message() about "Oh, I'm doing this too". The second patch includes the functionality of the first. Currently, I'm using a copied-and-pasted version of getDependencies, with my hacks in place and some moderately evil namespace traipsing to get at the rest of the utilities. I would much rather make use of the code in situ. - Allen S. Rout
*** getDependencies.R.orig 2010-04-23 14:43:53.361078503 -0400 --- getDependencies.R.new 2010-04-23 15:36:33.437078264 -0400 *************** *** 1,6 **** - getDependencies <- ! function(pkgs, dependencies = NA, available = NULL, lib = .libPaths()[1L]) { oneLib <- length(lib) == 1L if(is.logical(dependencies) && is.na(dependencies)) --- 1,5 ---- getDependencies <- ! function(pkgs, dependencies = NA, available = NULL, installed = NULL , lib = .libPaths()[1L]) { oneLib <- length(lib) == 1L if(is.logical(dependencies) && is.na(dependencies)) *************** *** 41,46 **** --- 40,46 ---- ## Here we are slightly more conservative libpath <- .libPaths() if(!lib %in% libpath) libpath <- c(lib, libpath) + if ( missing(installed) || is.na(installed) ) installed <- installed.packages(lib.loc = libpath, fields = c("Package", "Version")) not_avail <- character()
*** getDependencies.R.orig 2010-04-23 14:43:53.361078503 -0400 --- getDependencies.R.new2 2010-04-23 15:38:24.078078387 -0400 *************** *** 1,6 **** - getDependencies <- ! function(pkgs, dependencies = NA, available = NULL, lib = .libPaths()[1L]) { oneLib <- length(lib) == 1L if(is.logical(dependencies) && is.na(dependencies)) --- 1,5 ---- getDependencies <- ! function(pkgs, dependencies = NA, available = NULL, installed = NULL , verbose = TRUE , lib = .libPaths()[1L]) { oneLib <- length(lib) == 1L if(is.logical(dependencies) && is.na(dependencies)) *************** *** 41,46 **** --- 40,46 ---- ## Here we are slightly more conservative libpath <- .libPaths() if(!lib %in% libpath) libpath <- c(lib, libpath) + if ( missing(installed) || is.na(installed) ) installed <- installed.packages(lib.loc = libpath, fields = c("Package", "Version")) not_avail <- character() *************** *** 72,83 **** pkgs <- pkgs[pkgs %in% row.names(available)] if(length(pkgs) > length(p0)) { added <- setdiff(pkgs, p0) ! message(sprintf(ngettext(length(added), ! "also installing the dependency %s", ! "also installing the dependencies %s"), ! paste(sQuote(added), collapse=", ")), ! "\n", domain = NA) ! flush.console() } p0 <- pkgs } --- 72,85 ---- pkgs <- pkgs[pkgs %in% row.names(available)] if(length(pkgs) > length(p0)) { added <- setdiff(pkgs, p0) ! if ( verbose ) { ! message(sprintf(ngettext(length(added), ! "also installing the dependency %s", ! "also installing the dependencies %s"), ! paste(sQuote(added), collapse=", ")), ! "\n", domain = NA) ! flush.console() ! } } p0 <- pkgs }
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.