handlr: convert among citation formats
heavily influenced by, and code ported from https://github.com/datacite/bolognese
supported readers:
supported writers:
not supported yet, but plan to:
- crosscite
Installation
stable version
install.packages("handlr")
# OR
install.packages("handlr", repos = "https://dev.ropensci.org")
dev version
remotes::install_github("ropensci/handlr")
All in one
There’s a single R6 interface to all readers and writers
z <- system.file("extdata/citeproc.json", package = "handlr")
x <- HandlrClient$new(x = z)
x
#> <handlr>
#> doi:
#> ext: json
#> format (guessed): citeproc
#> path: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/handlr/extdata/citeproc.json
#> string (abbrev.): none
read the file
x$read(format = "citeproc")
the parsed content
x$parsed
#> <handl>
#> from: citeproc
#> many: FALSE
#> count: 1
#> first 10
#> id/doi: https://doi.org/10.5438/4k3m-nyvg
write out bibtex
cat(x$write("bibtex"), sep = "\n")
#> @article{https://doi.org/10.5438/4k3m-nyvg,
#> doi = {10.5438/4k3m-nyvg},
#> author = {Martin Fenner},
#> title = {Eating your own Dog Food},
#> journal = {DataCite Blog},
#> pages = {},
#> publisher = {DataCite},
#> year = {2016},
#> }
Choose your own adventure
Instead of using the HandlrClient
, you can use the
regular functions for each reader or writer. They are:
Convert data to data.frame
z <- system.file('extdata/bib-many.bib', package = "handlr")
res2 <- bibtex_reader(x = z)
handl_to_df(res2)
#> key id type bibtex_type
#> 1 Amano_2016 https://doi.org/10.1093%2fbiosci%2fbiw022 article article
#> 2 Bachelot_2016 https://doi.org/10.1890%2f15-1397.1 article article
#> citeproc_type ris_type resource_type_general additional_type
#> 1 article-journal JOUR <NA> JournalArticle
#> 2 article-journal JOUR <NA> JournalArticle
#> doi b_url
#> 1 10.1093/biosci/biw022 http://dx.doi.org/10.1093/biosci/biw022
#> 2 10.1890/15-1397.1 http://dx.doi.org/10.1890/15-1397.1
#> title
#> 1 Spatial Gaps in Global Biodiversity Information and the Role of Citizen Science
#> 2 Long-lasting effects of land use history on soil fungal communities in second-growth tropical rain forests
#> author
#> 1 Amano T., Lamming J., Sutherland W.
#> 2 Bachelot B., Uriarte M., Zimmerman J., Thompson J., Leff J., Asiaii A., Koshner J., McGuire K.
#> publisher is_part_of
#> 1 Oxford University Press ({OUP}) Periodical;{BioScience}
#> 2 Wiley-Blackwell Periodical;Ecological Applications
#> date_published volume first_page last_page state
#> 1 <NA> 66 393 400 findable
#> 2 <NA> <NA> <NA> <NA> findable