Lab 12: Bibliography

Preamble

The purpose of this lab is to add in-text references to your Quarto documents, and create a bibliography section in your rendered Quarto document that provides all the publication details of your references.

After completing this lab, you should be able to add in-text references to your Quarto documents, and create a bibliography section in your rendered Quarto document. You will know that you are done when you have created a rendered file where the results match the examples in this HTML file.

Preliminary Work

The following are good additional resources for the material covered in this lab:

Why are we here?

Citations and references are an important backbone of academic and scientific writing. Regardless of what field of study, or what type of work you do, you will always be building on the work of others that came before you. When you do, it’s important to use references in your writing to 1) give credit where credit is due, and 2) allow others to follow the progress and development of ideas over time. What’s more, properly referencing the work of others is important for giving your own work credibility; by referencing the foundations of your own arguments and claims, readers will be able to know if the premise of your work is reasonable. At a practical level, references are important for avoiding plagiarism, where you pass off the words and ideas of other people as your own.

An important feature of your citations will be providing enough information for your reader to find the original source you are referencing, so that they may be able to verify the claim your are making, or just learn more about the topic. With an ever-expanding collection of articles, books, manuscripts and websites in the information landscape, citations need to provide fine-grained detail about exactly where the original source can be located. While it is true that no software is required to manage and format your citations, doing so without the use of software is a tedious, repetitive and error prone process—just the type of problem software is most helpful in solving. So in today’s lab, we will focus on learning how to use the BibTeX citation management system to (mostly) painlessly add citations to your Quarto documents, and bring you one step closer to scientific publishing.

Lab instructions

What is a citation?

A citation has two components: 1) a brief in-text reference, which links to; 2) a detailed description in a bibliography section at the end of your document. The in-text reference should contain just enough information to uniquely identify the source you are referencing, and allow the reader to find the entry for this source in your bibliography. In the bibliography section (i.e., the full list of all works you cited in your writing), you should have all the detailed information your readers need to track down the original source and read it for themselves.

Adding in-text references to a Quarto file

Adding in-text references to your Quarto file has 3 steps to it:

  1. Collecting information about your references into a citation database, called a BibTeX file
  2. Connecting the BibTeX file to the Quarto document
  3. Referencing citations in your BibTeX file using the labels you’ve given to them

Creating a BibTeX file

As you know from your reading, a BibTeX file is a plain-text file that stores information about the sources you are referencing in a key/value format. So, before you reference a source in the text of your document, you must first collect information about those sources into a properly formatted BibTeX file. Luckily, creating a properly formatted BibTeX file usually isn’t too difficult, since nearly every search engine or publisher website where you find academic writings will allow you export a citation in BibTeX format.

Let’s create our very fist BibTeX file, so we can proceed to learning how to use it within Quarto documents. To make our first experience with BibTeX a bit simpler, we’ll create a BibTeX file that holds information about a single publication.

  • Go to https://scholar.google.com

  • Search for “Lum and Isaac To Predict and Serve”

  • Click the small “Cite” button at the bottom of the first search result

    The “Cite” button at the bottom of the first search result
  • In the pop-up window, click on the link at the bottom that says “BibTeX”

  • This should open a page of plain text, where the first line begins with @article

  • Copy this text, and paste it into a plain text file

    • You can open an empty plain text file by clicking on the green + sign icon and choosing “Text File”

    Opening a new text file in RStudio
  • Save this file in the same directory as your Quarto document.

    • It’s a good idea to name this file something simple and easy to remember, like refs.bib. The .bib file extension is important, because it signals to other people (and other computer programs!) that this file contains reference information formatted in the BibTeX style.

Connect your BibTeX file to your Quarto document

To make RStudio aware of your BibTeX file, you need to add a bibliography entry in your Quarto document’s YAML header. Scroll up to the very top of your Quarto document until your find the header section. You’ll know you’ve found the header when you see a list of fields like title: and format: all stored between a set of three dashes on the top and three dashes on the bottom. There, add a new line before the three dashes on the bottom with the option bibliography: refs.bib. This tells RStudio it can find all the information for your bibliography inside the file named refs.bib that is in the same folder as your Quarto document.

An example of a bibliography entry in the header of a Quarto document.
Warning

If you named your BibTeX file something other than refs.bib, make sure you change the value you give for the bibliograhy: option to match it. Using bibliography: refs.bib will only work if you named your BibTeX file refs.bib when you saved it.

Adding references in text

In-text citations generally come in two different styles, parenthetical citations and narrative citations. Narrative citation integrate the reference information into a sentence, while parenthetical citations place the reference information inside a parenthetical clause at the end of a sentence. Examples of each style are shown in Table 1.

Table 1: Examples of Narrative and Parenthetical citations
Narrative Style Parenthetical Style
Output: According to Lum & Isaac (2016), algorithmic bias occurs in the Oakland police department. Algorithmic bias occurs in the Oakland police department (Lum & Isaac, 2016).
text in .qmd: According to @lum2016predict, algorithmic bias occurs in the Oakland police department. Algorithmic bias occurs in the Oakland police department [@lum2016predict].

The narrative style works well when you only want to cite one or two sources, and wish to give them an active voice in your writing. The parenthetical style works better when you need to cite a long list of sources, or adopt a more passive writing style.

To add either style of citation to your document, you need to know the citekey for your citation. You can always find the citekey for your source by looking for the text right after the { on the very first line of the entry for your citation in your BibTeX file.

To add a narrative style citation to a sentence, write the citekey where you want the citation to appear in your sentence, directly preceded by an @ symbol. Be sure to write the citekey exactly as it appears in the BibTeX file (i.e., don’t add any spaces or dashes or capital letters), and don’t add any space between the @ symbol and the citekey. It’s a bit like mentioning someone on Twitter (or so I’m told…).

Question

Reproduce the narrative style citation shown in Table 1 in your own Quarto document. Make sure you render your Quarto document, and check that the in-text and bibliography citation formatting are correct.

To add a parenthetical style citation at the end of a sentence, write the citekey at the end of your sentence (but before the period!), directly preceded by an @ symbol. Then, surround the citation with square brackets: place the [ character before the @ symbol, and the ] character at the very end of the citekey.

Question

Reproduce the parenthetical style citation shown in Table 1 in your own Quarto document. Make sure you render your Quarto document, and check that the in-text and bibliography citation formatting are correct.

Adding information to a BibTeX entry

Google Scholar can do almost all the work for you, but it doesn’t always contain every piece of information about a reference that you need. And, information the exported citation can occasionally be wrong, and it’s your responsibility to correct it if need be.

One field that is always missing from citations exported from Google Scholar (but is almost always required by academic journals and scholars) are URLs and DOIs that link back to the original document on the internet. Ideally, every citation should have either a DOI or a URL, with DOIs preferred. Include a URL only if you can’t find a DOI.

To add a DOI link to your BibTeX entry for the Lum and Isaac paper, return to the Google Scholar search entry you used previously to export the citation, and this time click on the main link to visit the primary source (at Significance magazine).

DOI’s are a long string of letters and numbers used to uniquely identify a published work. These numbers always begin with the sequence 10.. To find the DOI for the Lum and Isaac article, look for a link towards to the top of the page that contains 10.1 in it.

Then, open your BibTeX file, and add a new field to the entry for the Lum and Isaac article to store this DOI information, using the screenshot below as a guide:

After adding the DOI information, render your Quarto document again, and take note of what has changed in the bibliography at the end of your document.

Changing the Citation style

By default, your citations and bibliography will use the Chicago style formatting. But, you may find yourself in a situation where another citation style is required. For example, an instructor may request you use MLA style citations for your research paper, or a publisher may require APA style citations for all submissions.

By using BibTeX as your reference manager, you won’t have to manually edit or re-type all your references if you need to change to another citation style. All you need to do is provide RStudio with a Citation Style Language file that describes how you want your citations to be formatted, and it does the rest.

Citation Style Language files (better known as CSL files) already exist for every major journal and citation format out there – the only time you’d ever need to write one yourself is if you’re inventing a new style of citation! Instead, all you need to know is where to find the CSL file for your style of choice, and how to connect it to your Quarto document.

Finding CSL files

A great place to find CSL files is the Zotero Style Repository, which allows you to search for CSL files for a specific format. Let’s use it to find the CSL file for the 7th Edition of the APA manual, and use that to change our citation style to APA style. Write “American Psychological Association” in the seach box, and find the entry in the search results that says “American Psychological Association 7th edition” (as shown in the screenshot below).

Then, click on this file to download it. Once it finishes downloading, move it into the same folder as your Quarto document and your BibTeX file.

Changing the Citation Style

The last thing to do is add a csl: option to the header of your Quarto document, and point it towards the apa.csl file your just downloaded and moved. This process will be just like when you added the bibliography option to your document’s header: Add a new line before the three dashes on the bottom of your header, and write the option csl: apa.csl. This tells RStudio it can find all the information on how to format and style your citations inside the file named apa.csl that is in the same folder as your Quarto document. The screenshot below shows what your header should look like when you are finished.

Quarto document header with the csl option added

Now when you render your Quarto document, all your citations will be formatted in APA style instead of Chicago style.

Citing a Web Page

Not everything you’ll need to cite appears in Google Scholar. In this class, sources are often in the form of web pages. You can create a simple BibTeX citation based on a few pieces of information about the web page: the title, the author, the year published (if available), the URL, and the date you’re accessing the page.

Here is an example citation for the FiveThirtyEight article that uses the avengers data we worked with in Lab 7.

@misc{avengers,
  title={Joining The Avengers Is As Deadly As Jumping Off A Four-Story Buiding},
  author={Hickey, Walt},
  date={2015},
  url={https://fivethirtyeight.com/features/avengers-death-comics-age-of-ultron/},
  urldate={2024-01-14}}

Note avengers on the first line - this is a citekey, the unique label given to your source within the BibTeX file you created. When creating your own citation like this, you’ll have to come up with your own citekey.

Question

Using the citation above as a template, create a citation for this article: Some People Are Too Superstitious To Have A Baby On Friday The 13th. Be sure to use an appropriate citekey.

There are many other types of sources you can cite using BibTeX. If you need to cite a different type of source, refer to this web page to see what information you need to collect and how to format it.

Submitting this lab

For this lab submission, you will be practicing creating citations for one of the datasets in your group’s rotation and then referencing those citations in your .qmd file.

Step 1: Final Project Prep, Rotation 5 - Ethical Considerations and Citations

In this first step, you will build on a previous .qmd file.

Step 1.1: Get Rotation Document

Before beginning this lab submission, you will need to get the rotation document from your fellow group mate. If you are unsure whose document you are inheriting, consult your Lab 8 submission for your group’s rotation schedule.

Step 1.2: Statement of Ethical considerations for your data

In this step, you will write a brief statement about your data concerning ethical issues.

  • First, write a few sentences about the data’s provenance. Where did this data come from? Who created/sourced it and for what purpose?
  • Second, list a few potential uses for this data (either realized in existing work or not-yet-realized)
  • Finally, write any potential harms or impacts that you can imagine could come from using this data

Step 1.3: Responding to Ethical considerations

Now that you have started considering ethical issues related to your data, draft a list of questions that you feel are critical to answer if your group selects this data for the final project submission.

Step 1.4: Tie the data to the Final Project’s goal

Finally, take a few minutes to consider the goal of the final project and how this dataset does (or does not) fit into that goal:

The final deliverable is contribute a new dataset for use in SDS 100 with a report that could be reproduced on another person’s computer. It is possible that the data you propose may end up in a future semester of SDS 100.

To that end, in 2-3 sentences, explain where you see this dataset fitting into SDS 100. Be specific in your recommendation, listing the particular topic (and Lab number) that you feel this dataset would work well.

Step 1.5: Add bibliography

Add at least one bibliographic citation to your document. Note that to do this you will need to:

  • Create a BibTeX database with at least one piece of scholarship
  • Create at least one reference in the text

Step 1.6: Double check the formatting from previous weeks

Finally, check all of the formatting from the previous weeks, including:

  • Lists
  • Use of bold and italics
  • Tables
  • Figures
  • Variable names
  • Cross-references
  • Spelling, grammar, and paragraph breaks

Step 1.7: Submit this document on Moodle AND rotate this document

Once you are happy with your document (including the formatting!), render your document. Check that everything renders as you expect and then:

  • Submit both the .qmd file and the .html file for this rotation document on Moodle under “Project Rotation 5” AND
  • Send the Quarto document (and any additional files need for rendering it, such as your .bib file and any local .csv files) to all members of your group

Step 2: Complete post lab reading

Please review all of the rotation documents in their entirety. Next week, you will be discussing the potential datasets and ultimately choosing one to be the center of your final project. Reflect on which of these datasets you would like to recommend for a future iteration of SDS100.

Step 3: Complete the Moodle Quiz

Complete the Moodle quiz for this lab.

Bibliography

Lum, K., & Isaac, W. (2016). To predict and serve? Significance, 13(5), 14–19. https://doi.org/10.1111/j.1740-9713.2016.00960.x