read_bib | R Documentation |
Read a bib file into a data.frame
read_bib(file, skip = 0L, max_lines = NULL, encoding = "UTF-8")
file |
File or connection |
skip |
The lines to skip |
max_lines |
The maximum number of lines to read |
encoding |
Assumed encoding of file (passed to |
Inspired and partially credited to bib2df::bib2df()
although this has no
dependencies outside of base functions and much quicker. This speed seems
to come from removing stringr
functions and simplifying a few *apply
functions.
This will also include as many categories as possible from the entry.
A data.frame
with each row as a bib entry and each column as a
field
?bib2df::bib2df
file <- "https://raw.githubusercontent.com/jmbarbone/bib-references/master/references.bib"
bibdf <- read_bib(file, max_lines = 51L)
if (package_available("tibble")) {
tibble::as_tibble(bibdf)
} else {
head(bibdf)
}
if (package_available("bib2df") & package_available("bench")) {
file <- system.file("extdata", "bib2df_testfile_3.bib", package = "bib2df")
# Doesn't include the 'tidying' up
foo <- function(file) {
bib <- ("bib2df" %colons% "bib2df_read")(file)
("bib2df" %colons% "bib2df_gather")(bib)
}
bench::mark(
read_bib = read_bib(file),
bib2df = bib2df::bib2df(file),
foo = foo(file),
check = FALSE
)[1:9]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.