Creates a list of package citations that can be turned into a
character string or data frame. This function should normally only be used
in an R Markdown or Quarto document, in which case pkrt_list()
automatically references the cited packages in the first (by default)
.bib
file specified in the YAML header if no references of the packages
already exist.
Details
This function automatically discards duplicate and base packages. You can use
pkrt_list()
in combination with renv::dependencies()
to cite all the
packages used in a project or directory.
Examples
# Create a list of citations
citations <- pkrt_list("pakret", "readr", "withr")
# You can then turn the citations into a character string
paste(citations, collapse = ", ")
#> [1] "'pakret' v. 0.2.2 [@pakret], 'readr' v. 2.1.5 [@readr], 'withr' v. 3.0.1 [@withr]"
# Or a data frame
as.data.frame(citations)
#> Package Version Reference
#> 1 pakret 0.2.2 @pakret
#> 2 readr 2.1.5 @readr
#> 3 withr 3.0.1 @withr