get_bibentries {Rdpack} | R Documentation |
Get all references from a Bibtex file
Description
Get all references from a Bibtex file.
Usage
get_bibentries(..., package = NULL, bibfile = "REFERENCES.bib",
url_only = FALSE, stop_on_error = TRUE)
Arguments
... |
arguments to be passed on to the file getting functions, character strings, see ‘Details’. |
package |
name of a package, a character string or NULL. |
bibfile |
name of a Bibtex file, a character string. |
url_only |
if TRUE, restrict percent escaping to BibTeX field |
stop_on_error |
if |
Details
get_bibentries
parses the specified file.
and sets its
names
attribute to the keys of the bib elements
(read.bib()
does this since version version 0.4.0 of
bibtex, as well). Here is what
get_bibentries
does on top of read.bib
(the details are
further below):
-
get_bibentries
deals with percent signs in URL's. if the current working directory is in the development directory of
package
,get_bibentries
will first search for the bib file under that directory.
bibfile
should normally be the base name of the Bibtex file.
Calling get_bibentries
without any "\dots"
arguments
results in looking for the Bibtex file in the current directory if
package is NULL or missing, and in the installation directory of the
specified package, otherwise.
Argument "..." may be used to specify directories.
If package
is missing or NULL, the complete path is obtained
with file.path(..., bibfile)
. Otherwise package
must be
a package name and the file is taken from the installation directory
of the package. Again, argument "..." can specify subdirectory
as in system.file
.
If the current working directory is in the development directory of
package
, the bib file is first sought there before resorting to
the installation directory.
Although the base R packages do not have files REFERENCES.bib,
argument package
can be set to one of them,
e.g. "base"
. This works since package bibtex provides bib
files for the core packages.
By default, get_bibentries
escapes unescaped percent signs in
all fields of bibtex objects. To restrict this only to field "url",
set argument url_only
to FALSE
.
get_bibentries
returns an object from class
"bibentryRd"
, which inherits from bibentry. The printing method
for "bibentryRd"
unescapes percent signs in URLs for some
styles where the escapes are undesirable.
Value
a bibentryRd object inheriting from bibentry
Author(s)
Georgi N. Boshnakov
References
There are no references for Rd macro \insertAllCites
on this help page.
Examples
r <- get_bibentries(package = "Rdpack")
r
print(r, style = "html")
## Bib from base R packages are disabled in Rdpack v2 (notify the
## maintainer of Rdpack or raise an issue on github if you wish this back).
##
## b <- get_bibentries(package = "stats")
## print(b[[1]], style = "R")
## print(b[[1]], style = "citation")
## here the url field contains percent encoding
fn_url <- system.file("examples", "url_with_percents.bib", package = "Rdpack")
u <- get_bibentries(bibfile = fn_url)
## the links produced by all of the following are valid
## and can be put in a browser
print(u, style = "html")
print(u, style = "bibtex")
print(u, style = "R")
print(u, style = "text")
print(u, style = "citation")
## The link here contains escapes but when put in a LaTeX document
## which uses the JSS style it generates correct clickable link,
## (see Details section)
print(u, style = "latex")
## here the journal field contains percent encoding
fn_other <- system.file("examples", "journal_with_percents.bib", package = "Rdpack")
j <- get_bibentries(bibfile = fn_url)
print(j, style = "html")
print(j, style = "bibtex")
print(j, style = "R")
print(j, style = "text")
print(j, style = "citation")
print(j, style = "latex")