infer_deps: Infer dependencies

View source: R/infer_deps.R

infer_depsR Documentation

Infer dependencies

Description

Infers the R packages that your R package depends on.

Usage

infer_deps(
  path = here::here("DESCRIPTION"),
  which = c("Imports", "Suggests"),
  imports_thresh = 2,
  imports = NULL,
  suggests = c("testthat", "rmarkdown", "markdown", "knitr", "remotes", "knitr", "covr"),
  errors = c("reported", "fatal", "ignored"),
  dev = FALSE,
  progress = TRUE,
  add_newlines = FALSE
)

Arguments

path

The path to a .R, .Rmd, .qmd, DESCRIPTION, a directory containing such files, or an R function. The default uses all files found within the current working directory and its children.

which

Which types of dependencies to return.

imports_thresh

The minimum number of times that a package has to be called within your package to assign it as an Import. If is called less times than this threshold, it will instead be assigned as a Suggest, which means it will not be installed by default.

imports

R packages that are exempt from the suggests_thresh rule and are instead automatically assigned as Imports.

suggests

R packages that are exempt from the suggests_thresh rule and are instead automatically assigned as Suggests.

errors

How should errors that occur during dependency enumeration be handled?

  • "reported" (the default): errors are reported to the user, but otherwise ignored.

  • "fatal": errors are fatal and stop execution.

  • "ignored": errors are ignored and not reported to the user.

dev

Boolean; include development dependencies? These packages are typically required when developing the project, but not when running it (i.e. you want them installed when humans are working on the project but not when computers are deploying it).

Development dependencies include packages listed in the Suggests field of a DESCRIPTION found in the project root, and roxygen2 or devtools if their use is implied by other project metadata. They also include packages used in ⁠~/.Rprofile⁠ if config$user.profile() is TRUE.

progress

Boolean; report progress output while enumerating dependencies?

add_newlines

Prefix each package name with a newline character and two spaces. This is useful for formatting DESCRIPTION files.

Value

A character vector of R package names.

Examples

#### Get example DESCRIPTION file ####
url <- "https://github.com/neurogenomics/templateR/raw/master/DESCRIPTION"
path <- tempfile(fileext = "DESCRIPTION")
utils::download.file(url,path)

deps <- infer_deps(path = path)

rworkflows documentation built on Sept. 23, 2024, 1:08 a.m.