Skip to contents

This function detects external packages used in an R project (package, compendium, website, etc.) and updates the sections Depends, Imports, and Suggests of the DESCRIPTION file.

A DESCRIPTION file can be created and added to an existing project with the function usethis::use_description().

All .R, .Rmd, and .qmd files are screened to identify packages called by library(foo), library("foo"), library('foo'), require(foo), require("foo"), require('foo') or foo::bar().

Different types of dependencies are handled with the following rules:

  • if a package is called with library(foo) or require(foo), it will be added to the section Depends of the DESCRIPTION file (except for vignettes and tests);

  • if the package is called with foo::bar(), it will be added to the section Imports of the DESCRIPTION file (except for vignettes and tests);

  • if the package is only used in vignettes or tests, it will be added to the section Suggests of the DESCRIPTION file.

This function also screens the NAMESPACE file (it detects packages mentioned as import(foo) and importFrom(foo,bar)) and @examples sections of roxygen2 headers. The detected packages are added in the Imports section of the DESCRIPTION file.

If the project is not an R package, non-standard folders are also screened (i.e. analyses/, paper/, etc.). The detected packages are added in the Imports section of the DESCRIPTION file.

Usage

add_deps()

Value

No return value.

Examples

if (FALSE) {
add_deps()
}