package_dependencies
Computations on the Dependency Hierarchy of Packages

Description

Lists the packages that a specified package requires, or the packages that require a specified package.

Usage

package_dependencies(packages = NULL, db = NULL,
  which = "strong", recursive = FALSE,
  reverse = FALSE, verbose = getOption("verbose"))

Arguments

packages a character vector of the names of packages for which dependency information is needed. If NULL, the default, the "Packages" column of the db argument is used.
db a character matrix resembling the output of available.packages or installed.packages. It must have a column named "Package". Typically, it has columns called "Depends", "Imports", "Linkingto", and "Suggests" that contain comma-separated lists of package names, possibly followed by package version restrictions such as "(>=3.4)". If NULL (the default), the result of available.packages() is used.
which a set of names of columns of db that contain comma-separated lists of columns. All packages named in these columns are considered to be required by the package in the "Package" column.

Some "nicknames" for commonly used sets of columns may also be used. "strong" means c("Depends", "Imports", "LinkingTo"), "most" adds "Suggests" to that, and "all" also adds "Enhances" to the set.

recursive
  • If FALSE (the default), then it returns only the packages immediately required by the packages named in the packages argument; in other words, those listed in the which columns for the packages row.
  • If TRUE, then it also returns the names of packages indirectly required, where "required" means mentioned in the set of column names listed in the which argument.
  • If a character vector, then it should be a set of column names (or a nickname for such a set), that define "required" for the indirectly required packages.
reverse a logical value.
  • If FALSE (the default), then it returns the names of packages required by the input packages.
  • If TRUE, then it returns names of packages that require the input packages.
verbose a logical value. This argument is currently ignored.

Details

Package version restrictions in db are ignored.
Value
returns a named list with an element for each element of the packages argument. The element for a given package includes the dependency information for that package only.
Examples
available <- rbind(
    c(Package="A", Depends=NA, Imports="B, E", LinkingTo=NA, Suggests=NA),
    c(Package="B", Depends=NA, Imports=NA, LinkingTo="C", Suggests=NA),
    c(Package="C", Depends=NA, Imports="D", LinkingTo=NA, Suggests=NA),
    c(Package="D", Depends=NA, Imports=NA, LinkingTo=NA, Suggests="E"),
    c(Package="E", Depends=NA, Imports=NA, LinkingTo=NA, Suggest=NA))
tools::package_dependencies(c("A", "B"), db = available)
tools::package_dependencies(c("A", "B"), db = available, which="most", recursive="strong")
tools::package_dependencies(c("A", "B"), db = available, recursive = TRUE)
tools::package_dependencies("D", db = available, reverse = TRUE, recursive = FALSE)
tools::package_dependencies("D", db = available, reverse = TRUE, recursive = TRUE)
Package tools version 6.1.4-13
Package Index