| Title: | Bibtex Parser |
|---|---|
| Description: | Utility to parse a bibtex file. |
| Authors: | Romain Francois [aut, cph] (ORCID: <https://orcid.org/0000-0002-2444-4226>, principal developer of bibtex R package), Diego Hernangómez [aut] (ORCID: <https://orcid.org/0000-0001-8457-4658>), James Joseph Balamuta [aut, cre] (ORCID: <https://orcid.org/0000-0003-2826-8458>), Scott Chamberlain [ctb] (ORCID: <https://orcid.org/0000-0003-1444-9135>), Kurt Hornik [ctb] (ORCID: <https://orcid.org/0000-0003-4198-9911>), Brian Ripley [ctb] (compilation fixes), Michael Koohafkan [ctb], Mathew W. McLean [ctb] (ORCID: <https://orcid.org/0000-0002-7891-9645>) |
| Maintainer: | James Joseph Balamuta <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.5.3 |
| Built: | 2026-09-22 18:29:27 UTC |
| Source: | https://github.com/ropensci/bibtex |
Parses a bib file into its entries without building
bibentry objects. This is the parser used by
read.bib, exported for packages that process the entries
differently.
do_read_bib(file, encoding = "unknown", srcfile)do_read_bib(file, encoding = "unknown", srcfile)
file |
file name |
encoding |
encoding |
srcfile |
Deprecated |
The parser is greatly inspired from the ‘bibparse’ library.
A list with one element per entry, leaving out @string,
@preamble and @comment blocks. Each element is a character
vector of field values, named by field as written, with the outer braces
or quotes removed and the file's @string macros expanded. Its
attributes are entry (the entry type as written), key (the
citation key) and srcref (the line numbers from the start of the
entry up to the next entry or the end of the file). An empty file, or one
holding only comments, gives an empty list.
entries <- do_read_bib(system.file("bib", "xampl_single.bib", package = "bibtex" )) attr(entries[[1]], "key") entries[[1]][["title"]]entries <- do_read_bib(system.file("bib", "xampl_single.bib", package = "bibtex" )) attr(entries[[1]], "key") entries[[1]][["title"]]
Parser for bibliography databases written in the bib format.
read.bib( file = findBibFile(package), package = "bibtex", encoding = "unknown", header, footer )read.bib( file = findBibFile(package), package = "bibtex", encoding = "unknown", header, footer )
file |
bib file to parse. By default, the file
‘REFERENCES.bib’ in the root directory of the package given by
the |
package |
package from which we want to read the bibliography.
Only used if |
encoding |
encoding |
header |
DEPRECATED. |
footer |
DEPRECATED |
An object of class "bibentry", similar to those obtained by the
bibentry function.
Nelson H. F. Beebe. bibparse 1.04. 1999. https://www.math.utah.edu/~beebe/
## this package has a REFERENCES.bib file bib <- read.bib(package = "bibtex") ## bibtex collects bibtex entries for R base packages base.bib <- read.bib(package = "base")## this package has a REFERENCES.bib file bib <- read.bib(package = "bibtex") ## bibtex collects bibtex entries for R base packages base.bib <- read.bib(package = "base")
Generates a Bibtex file from a bibentry object or a list of
packages. It is useful for adding relevant citations in Sweave documents.
write.bib(entry, file = "Rpackages.bib", append = FALSE, verbose = TRUE)write.bib(entry, file = "Rpackages.bib", append = FALSE, verbose = TRUE)
entry |
a |
file |
output Bibtex file. |
append |
logical. If |
verbose |
a logical to toggle verbosity. |
the list of Bibtex objects – invisibly.
Renaud Gaujoux, based on the function Rpackages.bib
from Achim Zeileis (see References).
[R] Creating bibtex file of all installed packages? Achim Zeileis. R-help mailing list.
tmp <- tempfile(fileext = ".bib") write.bib(c("bibtex", "utils", "tools"), file = tmp) bibs <- read.bib(tmp) tmp2 <- tempfile(fileext = ".bib") write.bib(bibs, tmp2) unname(tools::md5sum(tmp) == tools::md5sum(tmp2)) unlink(c(tmp, tmp2))tmp <- tempfile(fileext = ".bib") write.bib(c("bibtex", "utils", "tools"), file = tmp) bibs <- read.bib(tmp) tmp2 <- tempfile(fileext = ".bib") write.bib(bibs, tmp2) unname(tools::md5sum(tmp) == tools::md5sum(tmp2)) unlink(c(tmp, tmp2))