| Title: | Cite 'R' Packages on the Fly in 'R Markdown' and 'Quarto' |
| Version: | 0.3.1 |
| Description: | References and cites 'R' and 'R' packages on the fly in 'R Markdown' and 'Quarto'. 'pakret' provides a minimalist API that generates preformatted citations for 'R' and 'R' packages, and adds their references to a '.bib' file directly from within your document. |
| License: | GPL (≥ 3) |
| URL: | https://arnaudgallou.github.io/pakret/, https://github.com/arnaudgallou/pakret |
| BugReports: | https://github.com/arnaudgallou/pakret/issues |
| Depends: | R (≥ 3.6.0) |
| Imports: | knitr (≥ 1.51), readr (≥ 1.0.0), rmarkdown |
| Suggests: | callr (≥ 3.7.5), pkgload, testthat (≥ 3.0.0), usethis, withr (≥ 2.5.0) |
| Config/Needs/website: | arnaudgallou/cygne |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-04-15 10:04:32 UTC; arnaud |
| Author: | Arnaud Gallou |
| Maintainer: | Arnaud Gallou <arangacas@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-15 10:20:02 UTC |
pakret: Cite 'R' Packages on the Fly in 'R Markdown' and 'Quarto'
Description
References and cites 'R' and 'R' packages on the fly in 'R Markdown' and 'Quarto'. 'pakret' provides a minimalist API that generates preformatted citations for 'R' and 'R' packages, and adds their references to a '.bib' file directly from within your document.
Author(s)
Maintainer: Arnaud Gallou arangacas@gmail.com (ORCID) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/arnaudgallou/pakret/issues
Cite R or an R package
Description
Creates a preformatted citation for R or an R package. This
function is normally used within an R Markdown or Quarto document, where
pkrt() automatically references the cited package to the first (by
default) .bib file specified in the YAML header if no reference for the
package already exists.
Usage
pkrt(pkg)
Arguments
pkg |
Name of the package to cite. You can use |
Value
A character string with S3 class AsIs.
Examples
pkrt("pakret")
pkrt("R")
Cite a collection of R packages
Description
Creates a list of package citations that can be converted into a
character string or data frame. This function is normally used within an R
Markdown or Quarto document, where pkrt_list() automatically references
the cited packages in the first (by default) .bib file specified in the
YAML header if no reference for the packages already exists.
Usage
pkrt_list(...)
Arguments
... |
Character vectors, separated by commas, of packages to cite. |
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.
Value
A list of package citations with S3 class pkrt_list.
Examples
# Create a list of citations
citations <- pkrt_list("pakret", "readr", "knitr")
# You can then turn the citations into a character string
# Note that this is done automatically in inline chunks
paste(citations, collapse = ", ")
# Or a data frame
as.data.frame(citations)
Configure pakret's settings
Description
This function lets you configure pakret's settings, for example,
to customize citation templates or specify which .bib file should store
the references.
Usage
pkrt_set(...)
Arguments
... |
Key-value pairs, separated by commas, of parameters to set. See details. |
Details
Valid parameters are:
-
bib
<character|numeric> = 1L
Name or index of the.bibfile to save references to. -
pkg
<character> = "the ':pkg' package version :ver [:ref]"
Template used to cite a package. -
pkg_list
<character> = "':pkg' v. :ver [:ref]"
Template used inpkrt_list(). -
r
<character> = "R version :ver [:ref]"
Template used to cite R. -
sep
<character> = ", "
Separator used between packages in inline chunks. -
sep_last
<character> = ", and "
Separator used between the last two packages in inline chunks.
New settings only apply to citations that come after pkrt_set(). This means
you can redefine the same settings multiple times in the same document to
alter pakret's behavior for a few specific citations only.
Use NULL to reset a parameter to its default value.
Value
This function is called for its side-effect. It returns no value.
Examples
pkrt_set(pkg = "*:pkg* :ver :ref")
pkrt("pakret")
# `NULL` resets parameters to their default value
pkrt_set(pkg = NULL)
pkrt("pakret")