Title: | An R package to get and manage BibTeX/YAML/JSON references |
---|---|
Description: | The package \textbf{refR} retrieves author references from Scopus Search and Crossref APIs and returns references as BibTeX files (function \code{\link[refR]{getRefs}}). It also allows to convert BibTeX files in more readable formats (i.e. YAML and JSON) by calling the software pandoc-citeproc (functions \code{\link[refR]{getRefs}} and \code{\link[refR]{bib2yaml}}). Information in references files can be cleaned using the function \code{\link[refR]{cleanRefs}}. This function translates special characters (accented characters and other LaTeX tags) and also cleans author names (detection of particle in family names, removal of uppercase except for each first letter of family and given names, and shorten given name). |
Authors: | Nicolas Casajus [aut, cre], Kevin Cazelles [aut] |
Maintainer: | Nicolas Casajus <[email protected]> |
License: | GPL-3 |
Version: | 1.0 |
Built: | 2024-11-05 05:14:01 UTC |
Source: | https://github.com/inSileco/refR |
This function converts one (or many) BibTeX into YAML format using the software pandoc and pandoc-citeproc (called with the R functionsystem()
).
bib2yaml(data = NULL, file = NULL, path = ".", write = TRUE)
bib2yaml(data = NULL, file = NULL, path = ".", write = TRUE)
data |
A vector of collapsed BibTeX [strings] (i.e. each element of the vector/list is one single BibTeX) |
file |
A vector of BibTeX files to be converted |
path |
The path to the directory where YAML files will be written (ignored if |
write |
A boolean indicating if YAML will be written |
User has to specify one of data
or file
otherwise the function will return an error.
A list of YAML files (i.e. a tagged list). If write = TRUE
YAML files are also written in the directory specified by the argument path
.
# Coming soon...
# Coming soon...
Remove LaTeX tags and shorten authors names in YAML references
cleanRefs(files)
cleanRefs(files)
files |
Filename(s) of references in the YAML format to be cleaned |
The conversion from BibTeX to YAML (using pandoc-citeproc called by
getRefs
or bib2yaml
) removes a lot of
LaTeX tags. But this process is not perfect. The function cleanRefs
cleans the remaining special characters ('exotic' accents and other LaTeX).
Moreover information in BibTeX is not uniform for authors, so this function
also clean author names (detection of family names with particle, removal of
uppercase except for each first letter of family and given names, and shorten
given name). Note that journal, booktitle and article/chapter title are also
not uniform but this information comes from Scopus that is more standardize
than Crossref.
Finally we have to mention that cleaned YAML files erase their previous versions
(this function does not return any object).
If errors occur and if you still have BibTeX, you can use the function
bib2yaml
to regenerate the erased YAML file.
# Coming soon...
# Coming soon...
detectBin
detects and returns the path to a command binary.
detectBin(bin)
detectBin(bin)
bin |
a system command to be detected, as a character string. |
The path to the command binary.
detectBin('cd')
detectBin('cd')
This function queries the Scopus Search API to returned a list of references for one specific author.
Quality of metadata is increased by coupling Scopus results with a query of
the Crossref API called using the package rcrossref
.
Results are returned as BibTeX files (one per reference) but user can also choose two other formats: YAML and JSON.
The conversion is proceeded using pandoc and pandoc-citeproc (must be separately installed).
getRefs(api_key = NULL, author_id = NULL, date = NULL, sort = "pubyear", sleep = 5, folder = ".", format = c("bibtex", "yaml"), erase = FALSE)
getRefs(api_key = NULL, author_id = NULL, date = NULL, sort = "pubyear", sleep = 5, folder = ".", format = c("bibtex", "yaml"), erase = FALSE)
api_key |
A string indicating the user Scopus API Key obtained from the Elsevier Developer Portal |
author_id |
A string indicating the Scopus identifier of the author for which references have to be retrieve |
date |
A string indicating the year (or a range of years) for which references have to be retrieve (if |
sort |
A string indicating the field by which references will be ordered (one of |
sleep |
A positive numeric indicating the time interval (in seconds) between two consecutive Scopus queries (a Scopus query response is limited to 25 entries) |
folder |
A string indicating the folder (relative or absolute path) to write references |
format |
A string indicating the references format (the possible formats are |
erase |
A boolean specifing if a reference that already exists in the folder must be rewritten ( |
Before using this function user has to get a free Scopus API Key from the Elsevier Developer Portal (https://dev.elsevier.com/user/registration).
He also needs to know the author Scopus identifer by visiting the Scopus Author Search Portal (https://www.scopus.com/freelookup/form/author.uri).
This function works in four steps:
1) Get a list of references from Scopus API and keep only those with a DOI (all fields are returned except the authors list);
2) Complete the metadata (mainly the authors list) using the Crossref API called by the function cr_cn
(request by DOI);
3) Merge metadata from the two sources and keep the best (hopefully);
4) Write references (one file per reference) in the specified formats using pandoc-citeproc (for YAML and JSON).
We strongly recommend to convert references in YAML (and also keep BibTeX formats)
because this step (performed with pandoc-citeproc) translates a large amount of LaTeX tags (mainly accented characters).
But if you prefer you can also export references in BibTeX and then use the function bib2yaml
to convert them in YAML.
A list of BibTeX strings. BibTeX (if required) and other specified formats are also written in the directory specified by the argument folder
.
# Coming soon...
# Coming soon...