New UDRC report template released
By: Cory Stahle
April 3, 2019
The Utah Data Research Center (UDRC) released a template for forthcoming research reports this week. Version 1.0, released via GitHub, is available for use by any organization interested in authoring academic journal style reports. In order to generate reports with this template, some knowledge of coding in R and R Markdown is necessary. Basics of R Markdown will be discussed in this blog post, but more can be learned through this online tutorial.
FIGURE 1: REPORT TEMPLATE EXAMPLE
Click here to view PDF if not displayed below.
Accessing the template
In order to use the template you will need to download the R Studio software and several packages. The required packages are listed in the table below:
FIGURE 2: REQUIRED R PACKAGES
Each of these packages, with the exception of udrcTemplates, can be downloaded inside of R Studio by typing:
Once the first three packages have been installed, the udrcTemplates package can be added with the following command:
After adding the package from GitHub, the UDRC report template will be available upon creating a new R Markdown file via File -> New File -> R Markdown.
FIGURE 3: CREATING R MARKDOWN FILE BASED ON UDRC TEMPLATE
Using R Markdown
Each R Markdown file consists of three types of content:
- YAML metadata
- Code chunks
YAML metadata appears at the top of the document and is written between two sets of three dashes (see Figure 4). The purpose of this code is to adjust the underlying configuration of the document. In the UDRC template, values can be set for the title, header, author, date, abstract, and logo used. The output fields should not be adjusted or the PDF may not render properly.
FIGURE 4: YAML METADATA IN THE TEMPLATE
Once the YAML header is ended by the second set of three dashes, the text of the article begins. Section headings are created through the use of pound signs; otherwise, text is written in the same fashion as any other word processor.
FIGURE 5: BASIC TEXT IN R MARKDOWN
R code chunks
The last component of an R Markdown document is the ability to embed the R code. Within the text portion of a document, R code chunks can be inserted, which outputs statistical tables or graphs into the final report. R code is written between two sets of three back ticks.
FIGURE 6: SIMPLE R CODE CHUNK
How this template is different from a basic R Markdown file
When R Studio is installed, a few basic markdown templates are provided. The UDRC template modifies those underlying templates and adds additional functionality. This added functionality is accessed through commands inserted into the text portion of the markdown document. Figure 7 is an example of using the \twocol command to change the document to a two-column format. Figure 8 provides a list of all additional commands available through the template.
FIGURE 7: USING TEMPLATE COMMANDS
FIGURE 8: UDRC TEMPLATE COMMANDS