Reference Management in RMarkdown
- There are a variety of software one can use to generate manuscripts.
RMarkdown
has certain advantages such as the ability to writein-line
code and incorporate real-time data visualizations
- There are also numerous programs available to assist with managing references and citations, including, but not limited to EndNote, Reference Manager, and Mendeley
- We’ve incorporated EndNote into our lab’s workflow; thus the objective of this tutorial is to provide instructions on how to integrate an EndNote library into RMarkdown documents
- There are several good references that already exist that discuss bibliographies in RMarkdown (e.g. https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html)
- However, in this post, we list step-by-step instructions of one method that we’ve had success with that we believe add to the currently available resources because of the granularity of the detail we provide
- Hopefuly these extra details facilite your implementation of these two powerful software programs into your workflow
- Open your EndNote library of interest
- Select the references you wish to include (of note, here we are going to use all the references, so we just selected “all”)
- Now we are going to export these references
- File -> Export
- When the dialogue box opens (as below) go to the Output Style and Select BibTeX Export
- BibTex is not the only format that will work, but we are going to use the BibTex file format, becuase it is fairly straightforward and we’ve had good success with it
- BibTex is not the only format that will work, but we are going to use the BibTex file format, becuase it is fairly straightforward and we’ve had good success with it
- Select the folder that you are going to be saving your RMarkdown in
- Here we are using the “References_R_Markdown” folder that we created
- Here we are using the “References_R_Markdown” folder that we created
- Save the file as
bibliography
as a text only file with the extension.txt
- Now go and change the file extension from
.txt
to.bibtex
First view the
bibliography.bibtex
file by clicking on the file name in the Files box on the lower right in your RStudio IDE
Next, you need to identify the citation key for the reference you wish to insert
Here we are interested in entering the citation for the Shalhout et al. 2020 JAAD article
- Thus, we used the search tool and found the citation fairly rapidly
- Thus, we used the search tool and found the citation fairly rapidly
You’ll see that the citation starts with a
@article
followed by a curly bracketImmediately following the curley bracket is an alphanumeric code (here
@RN2687
).@article{RN2687, author = {Shalhout, S. Z. and Bloom, R. and Drake, L. and Miller, D. M.}, title = {Evaluation of the fragility of pivotal trials used to support US Food and Drug Administration approval for plaque psoriasis}, journal = {J Am Acad Dermatol}, ISSN = {1097-6787 (Electronic) 0190-9622 (Linking)}, DOI = {10.1016/j.jaad.2020.04.057}, url = {https://www.ncbi.nlm.nih.gov/pubmed/32320767}, year = {2020}, type = {Journal Article}}
The
@RN2687
is the citation key
You will use this information in your RMarkdown as your citation.
Seen the context of the IDE:
- Next, you need to format your YAML to let RMarkdown know which format your bibliography is in
- Since we exported our EndNote using
BibTex
style we will use the suffix.bibtex
as follows:
- Since we exported our EndNote using
Citation Style
pandoc
uses a Chicago author-date by default
If you desire another style, you can specify a CSL 1.0 style in the YAML, as seen here:
--- title: "Sample Document" output: html_document bibliography: bibliography.bibtex link-citations: yes csl: https://raw.githubusercontent.com/citation-style-language/styles/master/nature.csl ---
- Now we can enter our citation by placing the citation key (here
@RN2687
) within square brackets in the desired location in your text
- References will be placed at the end of your document, so make the last test in your RMarkdown # References
- Lastly,
knit
your document and you should see your desired references
- Coupling RMarkdown with a reference managing software is a great way to maximize your manuscript-generating efficiency
As always, please reach out to us with thoughts and feedback