This function uses
toBibtex to create bib entries for R packages and write
them in a file. Only the auto-generated citations are included for a package.
This function can facilitate the auto-generation of bibliography databases
for R packages, and it is easy to regenerate all the citations after updating
Package names. Packages which are not installed are ignored.
The (‘.bib’) file to write. By default, or if
Whether to fix some known problems in the citations, especially non-standard format of author names.
Width of lines in bibliography entries. If
Prefix string for keys in BibTeX entries; by default, it is
The citation is forced to be generated from the ‘DESCRIPTION’ file of
the package (
citation(auto = TRUE)). The keyword R-pkgname is
used for the bib item, where pkgname is the name of the package. All
references specified in the ‘CITATION’ file of the package are ignored.
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, ...). By comparison, paper/book citations don't change too
often, so it is not a lot of work even if you just cut and paste such
bibliography entries from
A list containing the citations. Citations are also written to the
file as a
Some packages on CRAN do not have standard bib entries, which was once
reported by Michael Friendly at
find this a real pain, and there are no easy solutions except contacting
package authors to modify their DESCRIPTION files. Anyway, the argument
tweak has provided ugly hacks to deal with packages which are known
to be non-standard in terms of the format of citations;
tweak = TRUE
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 [email protected] field (see the manual
Writing R Extensions) to make it easier for other people to cite R
knitr:::.tweak.bib 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
‘inst/misc/tweak_bib.csv’ in the source package.
Yihui Xie and Michael Friendly
1 2 3 4 5 6 7 8 9
write_bib(c("RGtk2", "gWidgets"), file = "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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.