Parses one or more R source files and extracts every qualified
package::function call, resolving the installed version of each package.
The resulting audit_report object is the entry point for the rest of the
reproducr workflow.
Arguments
- path
character(1). Path to a.R,.Rmd, or.qmdfile or a directory. When a directory is supplied, all R-ish source files are scanned recursively, excludingrenv/andpackrat/subdirectories. Defaults to"."(the current working directory).- renv
logical(1). IfTRUEand arenv.lockfile exists in the current working directory, package versions are read from the lockfile rather than the currently installed library. Useful for stable version reporting in CI environments. DefaultTRUE.- verbose
logical(1). Whether to print progress messages. DefaultTRUE.- x
An
audit_reportobject (forprint).- ...
Additional arguments (currently unused).
- object
An
audit_reportobject (forsummary).
Value
An S3 object of class "audit_report", a list containing:
callsA
data.framewith one row per detectedpkg::fncall, columnsfile,line,pkg,fn,pkg_version.envA list with R version, platform, OS, locale, and timezone.
renv_usedlogical– were versions sourced from a lockfile?timestampPOSIXcttimestamp of when the audit was run.pathsCharacter vector of files that were scanned.
Detection approach
audit_script() uses regular-expression matching on source text to extract
qualified calls of the form pkg::fn or pkg:::fn. It intentionally skips
comment lines (lines beginning with #, after trimming whitespace). For more
robust analysis, tools that operate on the parse tree (e.g. lintr) should
be used alongside reproducr.
What counts as a qualifying call?
Only qualified calls – those using :: or ::: – are detected.
Unqualified calls (e.g. filter(df, x > 0) without dplyr::) are not
detected because he package cannot be determined unambiguously from source
text alone. This is by design: qualifying calls is also a reproducibility
best practice.
See also
risk_score() to check detected calls against the
breaking-changes database; repro_report() to render the
full audit; certify() to lock a set of outputs as a baseline.
Examples
# Write a temporary script to audit
script <- tempfile(fileext = ".R")
writeLines(c(
"set.seed(237)",
"x <- dplyr::filter(mtcars, cyl == 4)",
"y <- dplyr::summarise(x, mean_mpg = mean(mpg))",
"z <- stats::rnorm(nrow(y))"
), script)
report <- audit_script(script, renv = FALSE, verbose = FALSE)
print(report)
#>
#> -- reproducr audit report [2026-06-10 21:14] --
#>
#> Files scanned: 1
#> Packages found: 2
#> Calls detected: 3
#> R version: 4.6.0
#> Platform: Linux 6.17.0-1015-azure
#> Versions from: installed library
#>
#> Next step: risks <- risk_score(report)
#>
# See the detected calls as a data frame
report$calls
#> file line pkg fn pkg_version
#> 1 /tmp/RtmpRobBZG/file1aec601b0ffe.R 2 dplyr filter <NA>
#> 2 /tmp/RtmpRobBZG/file1aec601b0ffe.R 3 dplyr summarise <NA>
#> 3 /tmp/RtmpRobBZG/file1aec601b0ffe.R 4 stats rnorm 4.6.0