EVOLUTION-MANAGER
Edit File: write_bib.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Generate BibTeX bibliography databases for R packages</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for write_bib {knitr}"><tr><td>write_bib {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Generate BibTeX bibliography databases for R packages</h2> <h3>Description</h3> <p>This function uses <code>utils::<a href="../../utils/html/citation.html">citation</a>()</code> and <code>utils::<a href="../../utils/html/toLatex.html">toBibtex</a>()</code> to create bib entries for R packages and write them in a file. It can facilitate the auto-generation of bibliography databases for R packages, and it is easy to regenerate all the citations after updating R packages. </p> <h3>Usage</h3> <pre> write_bib( x = .packages(), file = "", tweak = TRUE, width = NULL, prefix = getOption("knitr.bib.prefix", "R-") ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Package names. Packages which are not installed are ignored.</p> </td></tr> <tr valign="top"><td><code>file</code></td> <td> <p>The (‘<span class="file">.bib</span>’) file to write. By default, or if <code>NULL</code>, output is written to the R console.</p> </td></tr> <tr valign="top"><td><code>tweak</code></td> <td> <p>Whether to fix some known problems in the citations, especially non-standard format of author names.</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>Width of lines in bibliography entries. If <code>NULL</code>, lines will not be wrapped.</p> </td></tr> <tr valign="top"><td><code>prefix</code></td> <td> <p>Prefix string for keys in BibTeX entries; by default, it is <span class="samp">R-</span> unless <code><a href="../../base/html/options.html">option</a>('knitr.bib.prefix')</code> has been set to another string.</p> </td></tr> </table> <h3>Details</h3> <p>For a package, the keyword <span class="samp">R-pkgname</span> is used for its bib item, where <span class="samp">pkgname</span> is the name of the package. Citation entries specified in the ‘<span class="file">CITATION</span>’ file of the package are also included. The main purpose of this function is to automate the generation of the package citation information because it often changes (e.g. author, year, package version, ...). </p> <h3>Value</h3> <p>A list containing the citations. Citations are also written to the <code>file</code> as a side effect. </p> <h3>Note</h3> <p>Some packages on CRAN do not have standard bib entries, which was once reported by Michael Friendly at <a href="https://stat.ethz.ch/pipermail/r-devel/2010-November/058977.html">https://stat.ethz.ch/pipermail/r-devel/2010-November/058977.html</a>. I find this a real pain, and there are no easy solutions except contacting package authors to modify their DESCRIPTION files. Anyway, the argument <code>tweak</code> has provided ugly hacks to deal with packages which are known to be non-standard in terms of the format of citations; <code>tweak = TRUE</code> is by no means intended to hide or modify the original citation information. It is just due to the loose requirements on package authors for the DESCRIPTION file. On one hand, I apologize if it really mangles the information about certain packages; on the other, I strongly recommend package authors to consider the <span class="samp">Authors@R</span> field (see the manual <em>Writing R Extensions</em>) to make it easier for other people to cite R packages. See <code>knitr:::.tweak.bib</code> for details of tweaks. Also note this is subject to future changes since R packages are being updated. If you want to contribute more tweaks, please edit the file ‘<span class="file">inst/misc/tweak_bib.csv</span>’ in the source package. </p> <h3>Author(s)</h3> <p>Yihui Xie and Michael Friendly </p> <h3>Examples</h3> <pre> write_bib(c("RGtk2", "gWidgets"), file = "R-GUI-pkgs.bib") unlink("R-GUI-pkgs.bib") write_bib(c("animation", "rgl", "knitr", "ggplot2")) write_bib(c("base", "parallel", "MASS")) # base and parallel are identical write_bib("cluster", prefix = "") # a empty prefix write_bib("digest", prefix = "R-pkg-") # a new prefix write_bib("digest", tweak = FALSE) # original version # what tweak=TRUE does str(knitr:::.tweak.bib) </pre> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>