plot(cars)
rticles
Question
One team member should navigate to the final-report
folder in your GitHub repo. Delete final-report.qmd
, _extensions
, and final-report-files
. Commit your changes and have your remaining group members pull them.
Writing Reports in R
The rticles
package provides a series of LaTeX-based RMarkdown templates that support document preparation. It makes it possible to write documents in markdown and knit them in ways that align with various standardized formatting conventions. rticles
documents can only be output as PDFs.
Installing rticles
To install rticles
, in your console enter:
install.packages("rticles")
Question
Install the rticles
package.
Selecting a Template
Different academic journals have different expectations for how manuscripts will be formatted. Journals may differ in things like: - where titles, authors, and abstracts appear in the text - fonts and font sizes - margins and margin sizes - number of columns - how headings and sub-headings are enumerated - how headers, footers and page numbers appear - …and so on.
Once the package is installed, you can select a template in RStudio as follows: File > New File > RMarkdown > From Template
In this course, we are going to use the MDPI template.
Question
A different group member should open your group GitHub repo. One team member should create a new RMarkdown file with the MDPI Template to be stored in the main directory. You can call this term-paper
. This will create a folder with this name in your main directory. Commit your changes and have your team members pull the changes.
When you create this folder, you will notice a number of files needed to compile the document. Here is a breakdown of some important files:
- the .Rmd file is where you will compose the report
- the .bib file is where the citations will be stored
- the .cls file is where the rules for formatting the paper according to MDPI standards are stored. You don’t need to edit this file.
- the .bst files are where the rules for formatting citations are stored. You don’t need to edit this file.
YAML Header
rticles
will take care of most of the styling of your document for you via the rules in the .cls file. However to provide the system with the metadata it needs to format your document, there are a series of tags that you will fill out in the YAML header of the .Rmd file, detailing things like what is the title, who are the authors, what are the keywords, etc. Here is an example:
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice@example.com
affiliation: Some Institute of Technology
orcid: 0000-0000-0000-0000
- name: Bob Security
email: bob@example.com
affiliation: Another University
abstract: |
This is the abstract.
It consists of two paragraphs.
bibliography: sigproc.bib
csl: acm-sig-proceedings.csl
output: rticles::acm_article
---
Question
Have all group members add their names and affiliations (including address) to the term-paper.Rmd
YAML header. Note how, in this format, authors and affiliations are reported in two separate sections of the header. Discuss a strategy for avoiding merge conflicts when doing this. Be sure to Knit the document, and then commit, push, and pull changes.
Question
Create an ORCID. Every group member should add their ORCID to the YAML header in term-paper.Rmd
. Notice how this will go right below the affiliation. Knit, commit, push, and pull changes.
Abbreviations
Note that in this YAML header you can list abbreviations that may appear in your final report, and write out their longer phrases.
Question
As a group, identify one abbreviation that will likely appear in your final report. Have one team member add the short and long version to the YAML header. Knit, commit, push, and pull changes.
There are several other sections of the YAML header that you should fill out as a team as you are putting together your first draft.
Citing Sources
Zotero is a tool for managing citational metadata. It is a powerful way to keep all of the information you need to construct bibliographies in one place. We are going to use Zotero in this course because we will need to citational metadata to reference material in our final reports.
Question
If you don’t already have Zotero installed, you can install it from this link. Click on the
Download
button and follow the instructions.Download the Chrome Connector linked on the same page.
Note that to be able to use the Zotero Chrome Connector, the Zotero app needs to be running on your desktop.
When Web developers has designed web pages effectively, Zotero can parse the pages to pull citational metadata from the page. Most academic journals, news sites, and book publishers have set up their websites like this. We need this metadata to effectively build bibliographies for our final reports. To get the citational metadata for a source, you should follow these steps:
Once you have found the paper, article, or website you want to cite, click on the Zotero Connector extension on your Chrome window. This should be located in the top right corner of your Chrome window.
Then, go to the Zotero app on your desktop. Locate the title corresponding to your source, right click on it, and then click on Export Item. This will open up an options tab.
On the options tab, make sure that :
- the Format is set to BibTeX
- The Export Notes box is checked
- The Character Encoding option is set to Unicode (UTF-8)
- Then click OK and save the file.
Question
Navigate here, add the citational metadata to Zotero and then export the citation to a file on your computer.
These steps saved the citation in a bibtex format, which is a format that LaTeX can parse to create bibliographies. How do we then reference this citation in our projects?
Open the file where you had saved the citation created on Zotero.
Copy the citation and paste it to the
mybibfile.bib
file in yourterm_paper
folder created with therticles
package.Your newly added citation will look something like this:
@article{CMS_HCC_Eval, title = {Evaluation of the {CMS}-{HCC} {Risk} {Adjustment} {Model}, {Final} {Report}}, language = {en}, pages = {127}, file = {Evaluation of the CMS-HCC Risk Adjustment Model, F.pdf:/Users/swahabhattacharya/Zotero/storage/AAWN6DS6/Evaluation of the CMS-HCC Risk Adjustment Model, F.pdf:application/pdf}, author = {Pope, Gregory C. and Kautter, John and Ingber, Melvin J. and Freeman, Sara and Sekar, Rishi and Newhart, Cordon} }
The
@article
at the beginning of the citation describes the kind of source you are citing. TheCMS_HCC_Eval
right after it is the name of your citation – this is what you will use to reference your source in your paper.Now, to reference this citation in your paper, go to the point in the text where you are citing the paper. Then, add the citation by adding the name of your citation to your paper like this [@name_of_reference]. This will look something like:
CMS conducts comprehensive evaluations of its CMS-HCC model on a regular basis [@CMS_HCC_Eval].
This will automatically create a citation for you, which shows up at the end of the paper once you knit the .Rmd file.
Question
Add the article that you just added to Zotero to your .bib file in term-paper
. Then cite the paper you just added to Zotero somewhere in the text of term-paper.Rmd
. Knit the document to ensure that the citational formatting worked.
Tips and Tricks
Referencing and Visualizations
To reference data visualization or an image at a particular point in your paper, first name to the R chunk where you create the visualization or read in the image. This will look something like this:
{r name}
Then, go to the point in the paper where you want to link this graphic, and add the reference like so:
(\ref{fig:name})
. This will automatically number the visualizations and create references for them.
Question
Create an R chunk in term-paper.Rmd
, and name it example-plot. Enter the following code.
Use the strategy outlined above to link the reference to the plot to a certain piece of example text in term-paper.Rmd
.