Chapter 4 Managing references
In this first chapter, you will familiarize yourself with one of the important aspects of a data pipeline: managing your references.
For this specific task, we will use an open source software called Zotero.
At the end of the chapter, you should be able to:
- understand the power of Zotero.
- understand the necessity to manage your references in a programmatic way.
If you do not already have Zotero yet, download the last version now! Also, install the “Zotero Connector” avaible on the same link to save to Zotero from your browser directly.
4.3 Better BibTeX
Better BibTeX (BBT) is an extension for Zotero and Juris-M that makes it easier to manage bibliographic data, especially for people authoring documents using text-based toolchains (e.g. based on LaTeX / Markdown).
First, you need to install BBT by downloading the latest release
Once it is done, open Zotero and do the following:
- In the main menu go to Tools > Add-ons
- Select ‘Extensions’
- Click on the gear in the top-right corner and choose ‘Install Add-on From File…’
- Choose .xpi that you’ve just downloaded, click ‘Install’
- Restart Zotero
Before using the Addin
citr, make sure that your YAML contain this 3 options:
bibliography: nameOfTheBibFile.bib-> To choose the file containing your references
biblio-style: nameOfTheBiblioStyle-> To choose the style of your bibliography
Now that your YAML is setup, let’s install an addin called
Citr that facilitate the insertion of citations.
- Go to your console and enter the following code:
- Again in your console, write this code:
It might be possible that this message appear in your console. In this case enter the answer
Once it’s done, go to: Session > Restart R.
Now, you can click on the “Addins” button.
When you write “citation” in the search bar, you have an option labeled “Insert citations”.
Click on it! A window will open.
All your references will appear.
If it happens that you are using Rstudio without the
citr addin, here an option to make citations.
You still have to supply a .bib file to the bibliography parameter in the YAML (bibliography: nameOfTheBibFile.bib) for the R Markdown file knows where to look for reference.
Here some citation examples:
|Citation type||Syntax||Rendered citation|
|Citation within parentheses||[@james_1890]||(James, 1890)|
|Multiple citations||[@james_1890; @bem_2011]||(Bem, 2011; James, 1890)|
|In-text citations||@james_1890||James (1890)|
Additional information can be added to citations as pre- or postfixes. Pre- and postfixes can simply be added to each citation by writing inside the brackets ([e.g., @bem_2011]). Note that pre- and postfixes are bound to the enclosed citation, not to the set of all citations. Hence, a prefix will be reorder together with its citation, which may be undesirable. For example, [e.g., @james_1890; @bem_2011] yields (e.g., James, 1890; Bem, 2011). There is no way to prevent this behavior, so mind the alphabetical order of citations.
- Set up your YAML with .bib file
- Citr is easy to create citations
- Citations have a proper syntax
Getting your hands dirty