Title: | Identify External Packages Used in a Project |
---|---|
Description: | Screens all '.R', '.Rmd', and '.qmd' files to extract the name of packages used in a project. This package detects packages called with 'library(foo)', 'require(foo)', and 'foo::bar()' and adds these dependencies in the DESCRIPTION file in the sections Depends, Imports, and Suggests. |
Authors: | Nicolas Casajus [aut, cre, cph] |
Maintainer: | Nicolas Casajus <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.2 |
Built: | 2024-11-19 05:40:46 UTC |
Source: | https://github.com/FRBCesab/rdeps |
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.
add_deps()
add_deps()
No return value.
## Not run: add_deps() ## End(Not run)
## Not run: add_deps() ## End(Not run)