Chapter 4 Managing references

4.1 Introduction

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:

  1. understand the power of Zotero.
  2. understand the necessity to manage your references in a programmatic way.

4.2 Zotero

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

4.4 YAML

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
  • output:
    pdf_document:
    citation_package: biblatex
---
title: "nameOfYourDocument"
author: "nameOfTheAuthor"
date: "12/07/2019"
bibliography: nameOfTheBibFile.bib
biblio-style: nameOfTheBiblioStyle
output:
  pdf_document:
    citation_package: biblatex
---

4.5 Citr

Now that your YAML is setup, let’s install an addin called Citr that facilitate the insertion of citations.

  1. Go to your console and enter the following code:
install.packages("devtools")
  1. Again in your console, write this code:
devtools::install_github("crsh/citr")
  1. It might be possible that this message appear in your console. In this case enter the answer 1 as follow:

  2. Once it’s done, go to: Session > Restart R.

  3. Now, you can click on the “Addins” button.

  4. When you write “citation” in the search bar, you have an option labeled “Insert citations”.

  5. Click on it! A window will open.

All your references will appear.

4.6 Citations

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)
Year only [-@bem_2011] (2011)

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.

TL;DR

  • Set up your YAML with .bib file
  • Citr is easy to create citations
  • Citations have a proper syntax

Getting your hands dirty

In “Getting your hands dirty” of the chapter 2, you reproduced this report in Markdown.

To this same report, let’s add references! Get the bib file in the folder named chapter4 on Github. This is what the report with references should look like.