Package 'rbibtools'

Title: Toolbox to Handle BibTeX Files
Description: Imports, cleans, and exports BibTeX references exported by references management softwares (e.g. Mendeley, Zotero).
Authors: Nicolas Casajus [aut, cre, cph]
Maintainer: Nicolas Casajus <[email protected]>
License: GPL (>= 2)
Version: 0.0.1
Built: 2024-11-17 05:41:01 UTC
Source: https://github.com/FRBCesab/rbibtools

Help Index


Import bib files and clean BibTeX references

Description

Imports .bib files and cleans BibTeX references using the function bib2df::bib2df().

Usage

read_bib(
  path = ".",
  tags = c("bibtexkey", "category", "author", "title", "year", "volume", "booktitle",
    "editor", "journal", "pages", "institution", "publisher", "doi", "url", "abstract",
    "keywords", "annote"),
  categories = NULL,
  pattern = NULL
)

Arguments

path

a character of length 1. The name of the folder containing .bib files to read. All .bib files found in this folder will be imported.

tags

a vector of characters. BibTeX fields to extract (e.g. "author", "year", "title", etc.). See Details section.

categories

(optional) a vector of characters. Publications categories to import (e.g. "article", "book", etc.). See Details section. Default is NULL (all publications will be retrieved).

pattern

(optional) a vector of characters. This argument is used to select .bib files. For instance, if all .bib files start with CESAB- (i.e. ⁠CESAB-***.bib⁠), user can add pattern = 'CESAB-' to only read these .bib files.

Details

Valid tags values:

  • category: type of publication

  • bibtexkey: unique identifier of the publication

  • annote: user annotations

  • author: authors names

  • booktitle: title of the book

  • chapter: chapter number (for book chapter)

  • crossref: Crossref identifier

  • edition: edition number

  • editor: editors names

  • institution: institution name (for thesis and report)

  • journal: journal name (for scientific article)

  • month: month of the date of publication

  • number: issue number

  • pages: pages range or pages number or article number

  • publisher: publisher name (i.e. Elsevier, etc.)

  • series: series name

  • title: title of the publication

  • volume: volume number

  • year: year of the date of publication

  • doi: DOI (without https://doi.org/)

  • abstract: abstract of the publications

  • keywords: authors keywords

  • url: URL of the only publication

  • isbn: ISSN identifier of the book/journal

  • pmid: PMID identifier

Valid categories values:

  • article: scientific paper

  • book: book

  • incollection: book chapter

  • inproceedings: proceeding article

  • phdthesis: PhD thesis

  • techreport: technical report

Value

A data.frame with references fields in columns and references in rows.

Examples

path_to_bibs <- system.file("extdata", package = "rbibtools")
refs <- read_bib(path = path_to_bibs)

Translate LaTeX escaped characters in UTF-8

Description

Converts common LaTeX/BiBTeX escaped characters into UTF-8 encoding. For instance, ⁠{'{e}}⁠ will be translated in é.

Usage

replace_tex_tags(x)

Arguments

x

a vector of characters in which common LaTeX/BiBTeX escaped characters must be converted.

Value

A vector of characters.

Examples

replace_tex_tags("H{\\'{e}}t{\\'{e}}rog{\\'{e}}n{\\'{e}}it{\\'{e}}")
replace_tex_tags(c("Mon c{\\oe}ur", "El Ni{\\~{n}}o"))

Create a bib file from a data.frame

Description

Create a bib file from a data.frame

Usage

write_bib(data, file = "", append = FALSE)

Arguments

data

a data.frame with references fields in columns and references in rows.

file

a character of length 1. The name of .bib file to create.

append

a logical. If TRUE the data.frame will be appended to an existing file. Default is FALSE.

Value

No returned value.

Examples

## Import .bib file(s) ----
path_to_bibs <- system.file("extdata", package = "rbibtools")
refs <- rbibtools::read_bib(path = path_to_bibs)

## Export data.frame to .bib files ----
filename <- tempfile()
rbibtools::write_bib(refs, filename)