Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

readBibentry

Read and write bibentry files


Description

Read and write bibentry files.

Usage

readBibentry(file)

writeBibentry(be, file, style = c("Rstyle", "loose"))

Arguments

be

a bibentry object.

file

filename, a character string.

style

if "Rstyle" (default), wrap in c(), otherwise don't wrap and don't put commas between the entries, see Details section.

Details

These functions read/write bibentry objects from/to R source files. Two styles are supported. "Rstyle" is the format used by print(be, style = "R"), which writes the bibentry calls as a comma separated sequence wrapped in c(). Style "loose" writes the entries without separators and no wrapping.

writeBibentry writes the object to the specified file in the requested style (default is "Rstyle").

readBibentry reads the file and creates a bibentry object. It doesn't have argument for style, since that is inferred from the contents of the file.

bibentry() calls that throw errors are not included in the returned object. The errors are intercepted and converted to warnings, identifying the corresponding bibentry() calls by their keys, if present (otherwise the text of the whole bibentry is shown).

Value

for writeBibentry, NULL (invisibly)

for readBibentry, a bibentry object with the keys as names

Author(s)

Georgi n. Boshnakov

See Also

readBib and writeBib for reading/writing bib files,

Examples

bibs <- readBib(system.file("REFERENCES.bib", package = "rbibutils"),
                encoding = "UTF-8")
fn <- tempfile(fileext = ".bib")

writeBibentry(bibs, file = fn) # style = "Rstyle" (default)
cat(readLines(fn), sep = "\n")

writeBibentry(bibs, file = fn, style = "loose")
cat(readLines(fn), sep = "\n")

unlink(fn)

rbibutils

Convert Between Bibliography Formats

v2.1.1
GPL-2
Authors
Georgi N. Boshnakov [aut, cre] (R port, R code, modifications to bibutils' C code, conversion to Bibentry (R and C code)), Chris Putman [aut] (src/*, author of the bibutils libraries, https://sourceforge.net/projects/bibutils/), Richard Mathar [ctb] (src/addsout.c), Johannes Wilm [ctb] (src/biblatexin.c, src/bltypes.c)
Initial release
2021-04-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.