Builds citations from scan_usage() results. Package collections supply
their own citation records and package-citation policy.
Arguments
- usage
Results returned by
scan_usage().- package_citations
A named list or environment of package citation entries. Missing packages use
package_citation.- function_citations
A named list or environment of function citation entries, keyed by
"pkg::function".- package_citation
A function that accepts a package name and returns its citation entries. Defaults to
utils::citation().- always_cite
Character vector of packages to cite in addition to the packages found by the scan.
- format
One of
"bibtex"or"bibentry".
Examples
path <- tempfile(fileext = ".R")
writeLines("stats::median(1:3)", path)
universe <- build_universe_data(c("stats", "tools"))
usage <- scan_usage(path, universe$packages, universe$export_index, universe$origin_map)
#> ℹ Searching /tmp/Rtmpops0mG/file1a1121885638.R
cite_usage(usage)
#> @Manual{,
#> title = {R: A Language and Environment for Statistical Computing},
#> author = {{R Core Team}},
#> organization = {R Foundation for Statistical Computing},
#> address = {Vienna, Austria},
#> year = {2026},
#> doi = {10.32614/R.manuals},
#> url = {https://www.R-project.org/},
#> }
#>
#> @Manual{,
#> title = {R: A Language and Environment for Statistical Computing},
#> author = {{R Core Team}},
#> organization = {R Foundation for Statistical Computing},
#> address = {Vienna, Austria},
#> year = {2026},
#> doi = {10.32614/R.manuals},
#> url = {https://www.R-project.org/},
#> }
unlink(path)