find_deps: List places where dependencies are used

View source: R/find_deps.R

find_depsR Documentation

List places where dependencies are used

Description

A quick-and-dirty diagnostic tool to find dependency usage within top-level expressions (e.g. declared functions) in R scripts within a development package.

Usage

find_deps(path = ".", threshold = NULL)

Arguments

path

Path to the base directory of a package.

threshold

Only report on dependencies used in fewer than this many top-level expressions.

Details

This might be useful for package developers hoping to use need() in their package, and looking for good candidates for dependencies which could be moved from Imports to Suggests in the DESCRIPTION file.

Dependencies are searched for in two ways:

  • import() and importFrom() statements in the package's NAMESPACE file, such as those created by ⁠@import⁠ and ⁠@importFrom⁠ tags if creating package documentation with roxygen2

  • Functions called by using :: or ::: to access a dependency's namespace directly

This approach isn't perfect, but it should capture most dependency uses.

Value

A data frame, with one row per distinct top-level expression where a package is used. Packages used in the fewest places are listed first.

Examples

  find_deps(system.file("demopkg", package = "suggests"))


suggests documentation built on Aug. 8, 2023, 5:13 p.m.