Package 'bib2df'

Title: Parse a BibTeX File to a Data Frame
Description: Parse a BibTeX file to a data.frame to make it accessible for further analysis and visualization.
Authors: Philipp Ottolinger [aut], Thomas Leeper [ctb], Maƫlle Salmon [ctb], Paul Egeler [ctb], Emilio Xavier Esposito [ctb], Gianluca Baio [ctb, cre]
Maintainer: Gianluca Baio <[email protected]>
License: GPL-3
Version: 1.1.2.0
Built: 2024-12-09 05:15:08 UTC
Source: https://github.com/ropensci/bib2df

Help Index


Parse a BibTeX file to a tibble

Description

The BibTeX file is read, parsed, tidied and written to a tibble

Usage

bib2df(file, separate_names = FALSE, merge_lines = FALSE)

Arguments

file

character, path or URL to a .bib file.

separate_names

logical, should authors' and editors' names be separated into first and given name?

merge_lines

logical, set to FALSE by default. If set to TRUE identifies entries that span several lines and merges them

Details

For simplicity bib2df() unifies the reading, parsing and tidying of a BibTeX file while being aware of a standardized output format, different BibTeX styles and missing values in the BibTeX file.

When separate_names = TRUE, the respective columns contain a data.frame for each row. When FALSE, the respective columns contain character strings.

Value

A tibble.

Author(s)

Philipp Ottolinger

See Also

df2bib

Examples

# Read from .bib file:
path <- system.file("extdata", "bib2df_testfile_3.bib", package = "bib2df")
bib <- bib2df(path)
str(bib)

# Read from .bib file and separate authors' and editors' names:
bib <- bib2df(path, separate_names = TRUE)
str(bib)

Export a BibTeX tibble to a .bib file

Description

The BibTeX tibble is written to a .bib file

Usage

df2bib(x, file = "", append = FALSE, allfields = TRUE)

Arguments

x

tibble, in the format as returned by bib2df.

file

character, file path to write the .bib file. An empty character string writes to stdout (default).

append

logical, if TRUE the tibble will be appended to an existing file.

allfields

logical, if TRUE (default), the resulting bib output will include all the BibTeX fields contained in the df object. If FALSE only the fields with text will be included in the resulting bib object

Value

file as a character string, invisibly.

Author(s)

Thomas J. Leeper

Gianluca Baio

References

https://www.bibtex.org/Format/

See Also

bib2df

Examples

# Read from .bib file:
path <- system.file("extdata", "bib2df_testfile_3.bib", package = "bib2df")
bib <- bib2df(path)

# Write to .bib file:
# bibFile <- tempfile()
# df2bib(bib, bibFile)

# Use `append = TRUE` to add lines to an existing .bib file:
# df2bib(bib, bibFile, append = TRUE)