Learn R Programming

papaja (version 0.1.0.9479)

r_refs: Create a reference file for R and its packages

Description

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

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. The path and name of the file to be created or updated.
append
Logical. Indicates if existing .bib-files should be complemented or overwritten. See details.
prefix
Character. A prefix to be used for all R-package reference handles.
type_pref
Character. A vector of BibTeX entry types in the order to look for them in packages CITATION file. See details.
tweak
Logical. Indicates whether to fix some known problems in the 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). This behavior may result in redundant package references in your .bib-file, which will be cited when using cite_r. It is recommended to use a .bib-file dedicated to R-references, setting append = FALSE, and adding the file to the bibliography parameter in the document's yaml-header.

Beware that chunks loading packags should 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 .bib-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 prefered order of reference types specified in type_pref. By default, articles are cited if available rather than books. If no reference of the specified types is available, the first reference is used. If multiple references of the prefered type are given in the CITATION file all are cited. Finally, if no CITATION file exists a reference is generated from the DESCRIPTION file by citation.

See Also

cite_r, write_bib, citation, toBibtex

Examples

Run this code
NULL

Run the code above in your browser using DataLab