Title: Cite 'R' Packages on the Fly in 'R Markdown' and 'Quarto'
Version: 0.2.2
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.
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, readr (≥ 1.0.0), rmarkdown, utils, withr (≥ 2.5.0)
Suggests: callr (≥ 3.7.5), pkgload, testthat (≥ 3.0.0), usethis
Config/Needs/website: arnaudgallou/cygne
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2024-10-23 09:12:38 UTC; arnaudgallou
Author: Arnaud Gallou ORCID iD [aut, cre, cph]
Maintainer: Arnaud Gallou <arangacas@gmail.com>
Repository: CRAN
Date/Publication: 2024-10-23 10:40:03 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 minimalistic API that generates preformatted citations of 'R' and 'R' packages, and adds their reference to a '.bib' file directly from within your document.

Author(s)

Maintainer: Arnaud Gallou arangacas@gmail.com (ORCID) [copyright holder]

See Also

Useful links:


Cite R or an R package

Description

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.

Usage

pkrt(pkg)

Arguments

pkg

Name of the package to cite.

Value

A character string.

Examples

pkrt("pakret")

pkrt("R")

Cite a collection of R packages

Description

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.

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", "withr")

# You can then turn the citations into a character string
paste(citations, collapse = ", ")

# Or a data frame
as.data.frame(citations)

Configure pakret's settings

Description

This function allows you to configure pakret's settings, e.g. to customize citation templates or control which .bib file to save references to.

Usage

pkrt_set(...)

Arguments

...

Key-value pairs, separated by commas, of parameters to set. See details.

Details

Valid parameters are:

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.

Value

This function is called for its side-effect. It returns no value.

Examples

pkrt_set(pkg = ":pkg (v. :ver) :ref")
pkrt("pakret")

# `NULL` resets parameters to their default value
pkrt_set(pkg = NULL)
pkrt("pakret")