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 minimalistic API that generates preformatted citations of 'R' and 'R' packages, and adds their reference to a '.bib' file directly from within your document. |
Authors: | Arnaud Gallou [aut, cre, cph] |
Maintainer: | Arnaud Gallou <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.2 |
Built: | 2024-10-24 04:27:37 UTC |
Source: | CRAN |
Creates a preformatted citation of R or an R package. This
function should normally only be used in an R Markdown or Quarto document,
in which case pkrt()
automatically references the cited package in the
first (by default) .bib
file specified in the YAML header if no
references of the package already exist.
pkrt(pkg)
pkrt(pkg)
pkg |
Name of the package to cite. |
A character string.
pkrt("pakret") pkrt("R")
pkrt("pakret") pkrt("R")
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.
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", "withr") # You can then turn the citations into a character string paste(citations, collapse = ", ") # Or a data frame as.data.frame(citations)
# Create a list of citations citations <- pkrt_list("pakret", "readr", "withr") # You can then turn the citations into a character string paste(citations, collapse = ", ") # Or a data frame as.data.frame(citations)
This function allows you to configure pakret's settings, e.g. to
customize citation templates or control which .bib
file to save
references to.
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.
New settings only apply to citations that come after pkrt_set()
. This means
that 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 (v. :ver) :ref") pkrt("pakret") # `NULL` resets parameters to their default value pkrt_set(pkg = NULL) pkrt("pakret")
pkrt_set(pkg = ":pkg (v. :ver) :ref") pkrt("pakret") # `NULL` resets parameters to their default value pkrt_set(pkg = NULL) pkrt("pakret")