Re: [R] package dependency tree

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Tue 02 Jan 2007 - 18:07:07 GMT

roger koenker wrote:
> Is there a painless way to find the names of all packages on CRAN
> that "Depend" on a specified package?
>
Depends on how accurately you need them. These *probably* depend on "boot"

> x <- available.packages()

> rownames(x)[grep("boot",x[,"Depends"])]

 [1] "circular" "cramer" "DCluster" "equivalence" "np"

 [6] "pastecs" "relaimpo" "sensitivity" "simpleboot" "spdep"

[11] "survrec" "titan" "verification" "Zelig"

This allows visual inspection of the Depends fields too:

x[grep("boot",x[,"Depends"]), "Depends", drop=F]

(There could have been dependencies on, say, simpleboot). For increased precision, you'll need to grep more carefully, for "\\<boot\\>". Finally, catching indirect dependencies requires iterative application, something like this:

> f <- function(s) rownames(x)[grep(paste("\\<",s,"\\>",sep=""),x[,"Depends"])]
> (y <- f("boot"))

 [1] "circular"     "cramer"       "DCluster"     "equivalence"  "np"
 [6] "pastecs"      "relaimpo"     "sensitivity"  "simpleboot"   "spdep"
[11] "survrec"      "titan"        "verification" "Zelig"

> (y0 <- unlist(lapply(y,f)))
[1] "wle" "DCluster" "svcR" "gcmrec" "VDCutil"
> (y0 <- setdiff(y0,y))
[1] "wle" "svcR" "gcmrec" "VDCutil"
> (y <- union(y, y0))
[1] "circular" "cramer" "DCluster" "equivalence" "np" [6] "pastecs" "relaimpo" "sensitivity" "simpleboot" "spdep" [11] "survrec" "titan" "verification" "Zelig" "wle" [16] "svcR" "gcmrec" "VDCutil"

> (y0 <- unlist(lapply(y0,f)))

character(0)

...and stop at this point since there are no more dependents. Otherwise, repeat.  

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Wed Jan 03 08:04:54 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 02 Jan 2007 - 22:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.