Generates a Bibtex file from a bibentry object or a list of
packages. It is useful for adding relevant citations in Sweave documents.
Arguments
- entry
a
bibentryobject or a character vector of package names.- file
output Bibtex file.
- append
logical. If
TRUEcontent is appended to the file.- verbose
a logical to toggle verbosity.
Examples
tmp <- tempfile(fileext = ".bib")
write.bib(c("bibtex", "utils", "tools"), file = tmp)
#> Warning: could not determine year for ‘bibtex’ from package DESCRIPTION file
#> Converted 3 of 3 package citations to BibTeX
#> Writing 3 Bibtex entries ...
#> OK
#> Results written to file '/tmp/RtmpQjiCNq/file4e19818ca34.bib'
bibs <- read.bib(tmp)
tmp2 <- tempfile(fileext = ".bib")
write.bib(bibs, tmp2)
#> Writing 3 Bibtex entries ...
#> OK
#> Results written to file '/tmp/RtmpQjiCNq/file4e191985874a.bib'
unname(tools::md5sum(tmp) == tools::md5sum(tmp2))
#> [1] TRUE
unlink(c(tmp, tmp2))