| Title: | 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. |
| Authors: | Arnaud Gallou [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-1002-4247>) |
| Maintainer: | Arnaud Gallou <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.3.1.9000 |
| Built: | 2026-05-15 08:56:37 UTC |
| Source: | https://github.com/arnaudgallou/pakret |
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.
pkrt(pkg)pkrt(pkg)
pkg |
Name of the package to cite. You can use |
A character string with S3 class AsIs.
pkrt("pakret") pkrt("R")pkrt("pakret") pkrt("R")
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.
pkrt_list(...)pkrt_list(...)
... |
Character vectors, separated by commas, of packages to cite. |
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.
A list of package citations with S3 class pkrt_list.
# 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)# 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)
This function lets you configure pakret's settings, for example,
to customize citation templates or specify which .bib file should store
the references.
pkrt_set(...)pkrt_set(...)
... |
Key-value pairs, separated by commas, of parameters to set. See details. |
Valid parameters are:
bib<character|numeric> = 1L
Name or index of the .bib file 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 in pkrt_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.
This function is called for its side-effect. It returns no value.
pkrt_set(pkg = "*:pkg* :ver :ref") pkrt("pakret") # `NULL` resets parameters to their default value pkrt_set(pkg = NULL) pkrt("pakret")pkrt_set(pkg = "*:pkg* :ver :ref") pkrt("pakret") # `NULL` resets parameters to their default value pkrt_set(pkg = NULL) pkrt("pakret")