r_refs: Create a Reference File for R and R Packages

View source: R/r_refs.R

r_refsR Documentation

Create a Reference File for R and R Packages

Description

Creates a .bib-reference file for the installed R version and R-packages, so they can be cited in an R Markdown-document.

Usage

r_refs(
  file,
  append = TRUE,
  prefix = "R-",
  type_pref = c("Article", "Book"),
  tweak = TRUE
)

create_bib(
  x,
  file,
  append = TRUE,
  prefix = "R-",
  type_pref = c("Article", "Book"),
  tweak = TRUE
)

Arguments

file

Character. Path and name of the file to be created or updated.

append

Logical. Indicates if existing bibliography should be complemented or overwritten. See details.

prefix

Character. Prefix for all R-package reference handles.

type_pref

Character. A vector of BibTeX entry types in the order by which to prioritize packages CITATION entries. See details.

tweak

Logical. Indicates whether to fix some known problems in citations (based on write_bib).

x

Character. Names of packages to include in bibliography.

Details

r_refs is a wrapper for create_bib to create a bibliography for R and all attached or cached packages.

By default, if a file exists at the specified location, r_refs reads the file and appends missing citation information to the end of the file (create_bib always overwrites existing files). It is recommended to use a bibliography-file dedicated to R-references.

Beware that chunks loading packages should generally not be cached. r_refs will make all packages loaded in cached chunks citable, but it won't know when you remove a package from a cached chunk. This can result in unused package references in your bibliography-file that will be cited when using cite_r.

If a package provides citation information in a CITATION file, a reference is selected based on the preferred order of reference types specified in type_pref. By default, available articles are cited rather than books. If no reference of the specified types is available, the first reference is used. If multiple references of the preferred type are given all of them are cited. Finally, if no CITATION file exists a reference is generated from the DESCRIPTION file by citation.

Value

Invisibly returns the bibliography written to file.

See Also

cite_r(), knitr::write_bib(), utils::citation(), utils::toLatex()


papaja documentation built on Sept. 29, 2023, 9:07 a.m.