MyNixOS website logo
Description

Read 'Bibtex' Files and Convert Between Bibliography Formats.

Read and write 'Bibtex' files. Convert between bibliography formats, including 'Bibtex', 'Biblatex', 'PubMed', 'Endnote', and 'Bibentry'. Includes a port of the 'bibutils' utilities by Chris Putnam <https://sourceforge.net/projects/bibutils/>. Supports all bibliography formats and character encodings implemented in 'bibutils'.

CRANStatusBadge CRAN RStudio mirror downloads CRAN RStudio mirror downloads R build status codecov

Read and write 'BibTeX' files. Convert bibliography files between various formats, including BibTeX, BibLaTeX, PubMed, EndNote and Bibentry. Includes an R port of the bibutils utilities.

Installing rbibutils

Install the latest stable version from CRAN:

install.packages("rbibutils")

You can also install the development version of rbibutils from Github:

library(devtools)
install_github("GeoBosh/rbibutils")

Overview

Import and export 'BibTeX' files. Convert bibliography files between various formats. All formats supported by the bibutils utilities are available, see bibConvert() for a complete list. In addition, conversion from and to bibentry, the R native representation based on Bibtex, is supported.

readBib() and writeBib() import/export BiBTeX files. readBibentry() and writeBibentry() import/export R source files in which the references are represented by bibentry() calls.

The convenience function charToBib() takes input from a character vector, rather than a file. It calls readBib() or bibConvert().

bibConvert() takes an input bibliography file in one of the supported formats, converts its contents to another format, and writes the result to a file. All formats, except for rds (see below) are plain text files. bibConvert() tries to infer the input/output formats from the file extentions. There is ambiguity however about bib files, which can be either Bibtex or Biblatex. Bibtex is assumed if the format is not specified. Also, the xml extension is shared by XML-based formats. Its default is 'XML MODS intermediate' format.

The default encoding is UTF-8 for both, input and output. All encodings handled by bibutils are supported. Besides UTF-8, these include gb18030 (Chinese), ISO encodings such as iso8859_1, Windows code pages (e.g. cp1251 for Windows Cyrillic) and many others. Common alternative names are also accepted (e.g. latin1).

Bibentry objects can be input from an R source file or from an rds file. The rds file should contain a bibentry R object, saved from R with saveRDS(). The rds format is a compressed binary format`. Alternatively, an R source file containing one or more bibentry instructions and maybe other commands can be used. The R file is sourced and all bibentry objects created by it are collected.

Examples:

readBib

The examples in this section import the following file:

bibacc <- system.file("bib/latin1accents_utf8.bib", package = "rbibutils")

Note that some characters may not be displayed on some locales. Also, on Windows some characters may be "approximated" by other characters.

Import the above bibtex file into a bibentry object. By default TeX escape sequences representing characters are kept as is:

be0 <- readBib(bibacc)
be0
print(be0, style = "bibtex")

As above, using the direct option:

be1 <- readBib(bibacc, direct = TRUE)
## readBib(bibacc, direct = TRUE, texChars = "keep") # same
be1
print(be1, style = "bibtex")

Use the "convert" option to convert TeX sequences to true characters:

be2 <- readBib(bibacc, direct = TRUE, texChars = "convert")
be2
print(be2, style = "R")

(On Windows the Greek characters alpha and delta may be printed as 'a' and 'd' but internally they are alpha and delta.)

Use the "export" option to convert other characters to ASCII TeX sequences, when possible (currently this option doesn't handle well mathematical expressions):

be3 <- readBib(bibacc, direct = TRUE, texChars = "export")
print(be3, style = "bibtex")

bibConvert

Convert Bibtex file myfile.bib to a bibentry object and save the latter to `"myfile.rds":

bibConvert("myfile.bib", "myfile.rds", informat = "bibtex", outformat = "bibentry")
bibConvert("myfile.bib", "myfile.rds")

Convert Bibtex file myfile.bib to a Biblatex save to `"biblatex.bib":

bibConvert("myfile.bib", "biblatex.bib", "bibtex", "biblatex")
bibConvert("myfile.bib", "biblatex.bib", outfile = "biblatex")

Convert Bibtex file myfile.bib to Bibentry and save as rds or R:

bibConvert("myfile.bib", "myfile.rds")
bibConvert("myfile.bib", "myfile.R")

Read back the above files and/or convert them to other formats:

readLines("myfile.R")
file.show("myfile.R")
readRDS("myfile.rds")
bibConvert("myfile.rds", "myfile.bib")
bibConvert("myfile.R", "myfile.bib")

Assuming myfile.bib is a Biblatex file, convert it to Bibtex and save to bibtex.bib:

bibConvert("myfile.bib", "bibtex.bib", "biblatex", "bibtex")
bibConvert("myfile.bib", "bibtex.bib", "biblatex")

Assuming "myfile.med" is a PubMed file, convert it to Bibtex:

bibConvert(infile = "myfile.med", outfile = "bibtex.bib", informat = "med", outformat = "bib")
bibConvert(infile = "myfile.med", outfile = "bibtex.bib", informat = "med") # same

See bibConvert() for further examples and their results.

Metadata

Version

2.2.16

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows