Learn R Programming

pkgmaker (version 0.10.1)

write.bib: Generate a Bibtex File from Package Citations

Description

Generates a Bibtex file from a list of packages or all the installed packages. It is useful for adding relevant citations in Sweave documents.

Usage

write.bib(entry = NULL, file = "Rpackages.bib",
    prefix = "", append = FALSE, verbose = TRUE)

Arguments

entry
a bibentry object or a character vector of package names. If NULL, then the list of all installed packages is used.
file
output Bibtex file. It can be specified as a filename (as a single character string), NULL for stdout, or a link{connection} object. If file is a character string, an extension '.bib' is appended if not alrea
prefix
character string to prepend to the generated packages' Bibtex key.
append
a logical that indicates that the Bibtex entries should be added to the file. If FALSE (default), the file is overwritten.
verbose
a logical to toggle verbosity. If file=NULL, verbosity is forced off.

Value

  • the list of Bibtex objects -- invisibly.

encoding

utf8

Details

Multiple citations are handled by adding a numeric suffix to the Bibtex key (other than the first/main citation) as "%i" (e.g. pkg, pkg2, pkg3).

This function has now been integrated by Romain François in the bibtex package.

References

[R] Creating bibtex file of all installed packages? Achim Zeileis. R-help mailing list. https://stat.ethz.ch/pipermail/r-help/2009-December/222201.html

See Also

link{connection}, link{bibentry}

Examples

Run this code
#library(bibtex)
pkgmaker::write.bib(c('bibtex', 'utils', 'tools'), file='references')
bibs <- bibtex::read.bib('references.bib')
pkgmaker::write.bib(bibs, 'references2.bib')
md5 <- tools::md5sum(c('references.bib', 'references2.bib'))
md5[1] == md5[2]
stopifnot(md5[1] == md5[2])

# write to stdout()
pkgmaker::write.bib(c('bibtex', 'utils', 'tools'), file=NULL)

unlink(c('references.bib', 'references2.bib'))

Run the code above in your browser using DataLab