write.bib: Generate a Bibtex File from Package Citations

View source: R/bibtex.R

write.bibR Documentation

Generate a Bibtex File from Package Citations

Description

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

Usage

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

Arguments

entry

a bibentry object or a character vector of package names.

file

output Bibtex file.

append

logical. If TRUE content is appended to the file.

verbose

a logical to toggle verbosity.

Value

the list of Bibtex objects – invisibly.

Author(s)

Renaud Gaujoux, based on the function Rpackages.bib from Achim Zeileis (see References).

References

[R] Creating bibtex file of all installed packages? Achim Zeileis. R-help mailing list.

Examples

tmp <- tempfile(fileext = ".bib")
write.bib(c("bibtex", "utils", "tools"), file = tmp)
bibs <- read.bib(tmp)

tmp2 <- tempfile(fileext = ".bib")
write.bib(bibs, tmp2)
unname(tools::md5sum(tmp) == tools::md5sum(tmp2))

unlink(c(tmp, tmp2))

bibtex documentation built on Sept. 23, 2026, 1:08 a.m.