Learn R Programming

gtools (version 3.9.2)

getDependencies: Get package dependencies

Description

Get package dependencies

Usage

getDependencies(
  pkgs,
  dependencies = c("Depends", "Imports", "LinkingTo"),
  installed = TRUE,
  available = TRUE,
  base = FALSE,
  recommended = FALSE
)

Arguments

pkgs

character vector of package names

dependencies

character vector of dependency types to include. Choices are "Depends", "Imports", "LinkingTo", "Suggests", and "Enhances". Defaults to c("Depends", "Imports", "LinkingTo").

installed

Logical indicating whether to pull dependency information from installed packages. Defaults to TRUE.

available

Logical indicating whether to pull dependency information from available packages. Defaults to TRUE.

base

Logical indicating whether to include dependencies on base packages that are included in the R installation. Defaults to FALSE.

recommended

Logical indicating whether to include dependencies on recommended packages that are included in the R installation. Defaults to FALSE.

Value

A character vector of package names.

Details

This function recursively constructs the list of dependencies for the packages given by pkgs. By default, the dependency information is extracted from both installed and available packages. As a consequence, it works both for local and CRAN packages.

See Also

installed.packages, available.packages

Examples

Run this code
# NOT RUN {
## A locally installed package
getDependencies("MASS", installed = TRUE, available = FALSE)
# }
# NOT RUN {
## A package on CRAN
getDependencies("gregmisc", installed = FALSE, available = TRUE)
# }
# NOT RUN {
## Show base and recommended dependencies
getDependencies("MASS", available = FALSE, base = TRUE, recommended = TRUE)
# }
# NOT RUN {
## Download the set of packages necessary to support a local package
deps <- getDependencies("MyLocalPackage", available = FALSE)
download.packages(deps, destdir = "./R_Packages")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab