
Collect the package dependencies a set of code files declare
Source:R/reproducibility_check.R
repro_dependencies.RdWalks each code file with code_library_names() and returns the distinct
packages the paper's code loads, tagged with how each was referenced and
whether it is installable from CRAN, from a named GitHub/URL source, or is a
base/recommended package already shipped with R (so a run need not install
it). This is the input list a run would install; it is deliberately
name-only, because static analysis cannot know which version was used —
running against the latest packages and observing a break is itself a
finding (it argues the authors should have pinned versions).
Value
a data frame with columns package, source (cran, bioc,
github, url, or base), ref (the source path/ref for github/url,
else NA), and base (logical, TRUE for a base/recommended package). One
row per distinct package. Empty frame (same columns) when none are found.
Details
GitHub/URL sources are read from the code text, not the package name: a call
remotes::install_github("user/repo") names the source user/repo, which is
matched back to the package by the repo's basename. When a script pins a ref
(user/repo@v1.2), the ref is kept.
Examples
code_text <- c(
"library(dplyr)",
"remotes::install_github('tidyverse/ggplot2@v3.4.0')",
"x <- stats::sd(1:10)"
)
repro_dependencies(code_text)
#> package source ref base
#> 1 dplyr cran <NA> FALSE
#> 2 remotes cran <NA> FALSE
#> 3 stats base <NA> TRUE