Build IMPORTS edges from R files to package dependencies
Source:R/edge_builders.R
build_import_edges.RdDiscovers package dependencies at two levels:
Value
A data.frame with columns:
fromFile stem (or project identifier) where the import appears.
toPackage name being imported.
weightNumeric: edge weight (default
1).sourceCharacter:
"library","qualified", or"description".
Details
Explicit –
library(pkg)andrequire(pkg)calls in source files.Qualified –
pkg::fnandpkg:::fnpatterns (the package name is extracted as an import).DESCRIPTION – if a
DESCRIPTIONfile is found in the project root (or any ancestor up to two levels up), itsImports:andDepends:fields are parsed.
Each discovered dependency produces an edge from the file stem (or the
project root stem) to the package name. Base-R packages (base, methods,
utils, stats, datasets, graphics, grDevices) are included when
explicitly referenced but are labelled with source = "qualified" or
source = "description" for downstream filtering.
Examples
if (FALSE) { # \dontrun{
proj <- detect_rproject("/path/to/mypkg")
edges <- build_import_edges(proj$r_files, root = proj$root)
} # }