How to import Zotero files and convert the data into a bibliographic class
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Because of delays with my scholarship payment, if this post is useful to you I kindly ask a minimal donation on Buy Me a Coffee that shall be used to continue my Open Source efforts. If you need an R package or Shiny dashboard for your team, you can email me or inquiry on Fiverr. The full explanation is here: A Personal Message from an Open Source Contributor
You can send me questions for the blog using this form.
I got this question from a reader: How to import an RIS or bib-export file from Zotero (Reference Manager) and convert the data into a bibliographic class. Zotero is open access and its export cannot be read as easy as a Clavariate-bib export file. Some fields are missing, such as ID (Key in Zotero export) or CI for citations. Zotero does not extract this information and I do not need it.
The good news is that I use Zotero daily, and to answer this I will use the sub-collection I created for the Kendall’s correlation coefficient article.
After exporting that sub-collection to Zotero RDF, RIS and BIB, I realised it is not very straightforward to read this into R and export to a Clarivate-BIB file, and I had to create my own functions but those ended up being a few hundred lines and I organized those as an R package.
The code and data for this example are available on GitHub.
Install the zotero R package with:
remotes::install_github("pachadotdev/zotero")
You can see the code on GitHub and improve the functions.
Read a Zotero exported file like so:
library(zotero) x = read_zotero("bibliography.bib") y = read_zotero("bibliography.rdf") z = read_zotero("bibliography.ris")
The result is the same for each object:
names(z) [1] "df" "bib" z$df title 1 Buy Stata | Student single-user purchases (educational) 2 Buy Stata | Student Lab new purchases (educational) 3 A Deep Dive Into How R Fits a Linear Model ... author year 1 Stata Corp 2025 2 Stata Corp 2025 3 Matthew Drury 2016 ... z$bib Corp S (2025). “Buy Stata | Student single-user purchases (educational).” Stata Student single-user purchases, <https://www.stata.com/order/new/edu/profplus/student-pricing/>. Corp S (2025). “Buy Stata | Student Lab new purchases (educational).” Educational single-user new purchases, <https://www.stata.com/order/new/edu/lab-licenses/dl/>. Drury M (2016). “A Deep Dive Into How R Fits a Linear Model.” <https://madrury.github.io/jekyll/update/statistics/2016/07/20/lm-in-R.html>. ...
Export the result to a Clarivate-BIB file:
write_clarivate(z$bib, "export.bib") @misc{student-pricing, title = {Buy Stata | Student single-user purchases (educational)}, author = {Corp, Stata}, year = {2025}, url = {https://www.stata.com/order/new/edu/profplus/student-pricing/}, id = {student-pricing}, citations = {}, abstract = {Stata Student single-user purchases}, } @misc{dl, title = {Buy Stata | Student Lab new purchases (educational)}, author = {Corp, Stata}, year = {2025}, url = {https://www.stata.com/order/new/edu/lab-licenses/dl/}, id = {dl}, citations = {}, abstract = {Educational single-user new purchases}, } @misc{lm-in-R_html, title = {A Deep Dive Into How R Fits a Linear Model}, author = {Drury, Matthew}, year = {2016}, url = {https://madrury.github.io/jekyll/update/statistics/2016/07/20/lm-in-R.html}, id = {lm-in-R_html}, citations = {}, } ...
I hope this is useful 🙂 I added an optional email field in the form to notify when I answer the questions.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.