| cff_write_bib | R Documentation |
Export R objects representing citations to specific file formats:
cff_write_bib() creates a .bib file.
cff_write_citation() creates an R citation file as described in
Section 1.9 of Writing R Extensions (R Core Team 2026).
cff_write_bib(
x,
file = tempfile(fileext = ".bib"),
append = FALSE,
verbose = TRUE,
ascii = FALSE,
...
)
cff_write_citation(
x,
file = tempfile("CITATION_"),
append = FALSE,
verbose = TRUE,
...
)
x |
A |
file |
Name of the file to be created. If |
append |
A logical value. If |
verbose |
A logical value. If |
ascii |
A logical value. If |
... |
Arguments passed on to
|
When x is a cff object, it is converted to BibTeX using
toBibtex.cff().
For security reasons, if the file already exists, the function creates a backup copy in the same directory.
Invisibly returns NULL. This function is called for its side effect of
writing a file or displaying its contents.
R Core Team (2026). Writing R Extensions. https://cran.r-project.org/doc/manuals/r-release/R-exts.html.
vignette("bibtex-cff", package = "cffr"), knitr::write_bib() and the
following packages:
Work with BibTeX metadata:
as_bibentry(),
cff_read(),
cff_read_bib_text(),
encoded_utf_to_latex()
Write citation metadata files:
cff_write()
bib <- bibentry("Misc",
title = "My title",
author = "Fran Pérez"
)
my_temp_bib <- tempfile(fileext = ".bib")
cff_write_bib(bib, file = my_temp_bib)
cat(readLines(my_temp_bib), sep = "\n")
cff_write_bib(bib, file = my_temp_bib, ascii = TRUE, append = TRUE)
cat(readLines(my_temp_bib), sep = "\n")
# Create an R citation file.
# Use a system file.
f <- system.file("examples/preferred-citation-book.cff", package = "cffr")
a_cff <- cff_read(f)
out <- file.path(tempdir(), "CITATION")
cff_write_citation(a_cff, file = out)
# Check by reading with a meta object.
meta <- packageDescription("cffr")
meta$Encoding <- "UTF-8"
utils::readCitationFile(out, meta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.