Learn R Programming

reproducible (version 1.1.1)

pkgDep: Determine package dependencies, first looking at local filesystem

Description

This is intended to replace package_dependencies or pkgDep in the miniCRAN package, but with modifications for speed. It will first check local package directories in libPath, and it if the function cannot find the packages there, then it will use package_dependencies.

pkgDep2 is a convenience wrapper of pkgDep that "goes one level in", i.e., the first order dependencies, and runs the pkgDep on those.

This is a wrapper around tools::dependsOnPkgs, but with the added option of sorted, which will sort them such that the packages at the top will have the least number of dependencies that are in pkgs. This is essentially a topological sort, but it is done heuristically. This can be used to e.g., detach or unloadNamespace packages in order so that they each of their dependencies are detached or unloaded first.

Usage

pkgDep(
  packages,
  libPath,
  recursive = TRUE,
  depends = TRUE,
  imports = TRUE,
  suggests = FALSE,
  linkingTo = TRUE,
  topoSort = FALSE,
  repos = getOption("repos"),
  refresh = FALSE,
  verbose = getOption("reproducible.verbose")
)

pkgDep2( packages, recursive = TRUE, depends = TRUE, imports = TRUE, suggests = FALSE, linkingTo = TRUE, repos = getOption("repos"), refresh = FALSE, verbose = getOption("reproducible.verbose"), sorted = TRUE )

pkgDepTopoSort( pkgs, deps, reverse = FALSE, topoSort = TRUE, useAllInSearch = FALSE, returnFull = TRUE )

Arguments

packages

a character vector of package names.

libPath

The library path where all packages should be installed, and looked for to load (i.e., call library)

recursive

Logical. Should dependencies of dependencies be searched, recursively. NOTE: Dependencies of suggests will not be recursive. Default TRUE.

depends

Logical. Include packages listed in "Depends". Default TRUE.

imports

Logical. Include packages listed in "Imports". Default TRUE.

suggests

Logical. Include packages listed in "Suggests". Default FALSE.

linkingTo

Logical. Include packages listed in "LinkingTo". Default TRUE.

topoSort

Logical. If TRUE, the default, then the returned list of packages will be in order with the least number of dependencies listed in pkgs at the top of the list.

repos

The remote repository (e.g., a CRAN mirror), passed to either install.packages, install_github or installVersions.

refresh

There is an internal type of caching. If the results are wrong, likely set refresh = TRUE.

verbose

logical indicating if output should monitor the package search cycles.

sorted

Logical. If TRUE, the default, the packages will be sorted in the returned list from most number of dependencies to least.

pkgs

A vector of package names to evaluate their reverse depends (i.e., the packages that use each of these packages)

deps

An optional named list of (reverse) dependencies. If not supplied, then tools::dependsOnPkgs(..., recursive = TRUE) will be used

reverse

logical: if FALSE (default), regular dependencies are calculated, otherwise reverse dependencies.

useAllInSearch

Logical. If TRUE, then all non-core R packages in search() will be appended to pkgs to allow those to also be identified

returnFull

Logical. If TRUE, then the full reverse dependencies will be returned; if FALSE, the default, only the reverse dependencies that are found within the pkgs (and search() if useAllInSearch = TRUE) will be returned.

Value

A possibly ordered, named (with packages as names) list where list elements are either full reverse depends.

Examples

Run this code
# NOT RUN {
pkgDep("crayon")
pkgDep2("reproducible")
# }

Run the code above in your browser using DataLab