Learning How to Use R Markdown

What I Learned

In this class I learned how to create an rmd (R Markdown) file, and how to edit basic components of this file. I learned about the three main components of an rmd file:

1. The YAML

  • This is where the author, title of the document, and date go. You can also assign what type of document you want to create. I would need to download LaTeX or TeX in order to save as a PDF or Word document. I am not doing that for this assignment because I opened the web page to download those things and it was confusing and seemed like too much work for today.
  • In the YAML, you can also edit things like aesthetics and theme. In this document I have changed the theme to “solar”, using bootswatch. I believe this lives inside the bslib package.

2. The Text

  • This is where you can write out the main content of your document. What’s nice about text in rmd files as opposed to r files, is that you can write like you would in a word document. It is much more intuitive. There are also ways to update the layout and look of your text by editing the YAML theme.

3. The Code

  • Similar to r files, the code is what makes things actually run, and what differentiates an rmd file from a plain word or text file, in my opinion. Using code, you can run statistical computations as you would with an r file, input figures and graphs, and install packages/ run libraries to use various R tools and features. In the code you also have the option to keep things hidden in your final document output. This is nice because you can write your “messy” content such as packages, libraries, and models, but show only the final product in the end item. For example, I have several libraries loaded into this document, but using the include=FALSE line in my code hopefully you should not be able to see those in this document.

How This Applies to My Research

  • I am currently working on publishing a couple fact sheets through the OSU Extension office. I think that creating these in an rmd file would be really great. For example, I can easily add photos. This is my study species, ombus impatiens
  • I also think that r markdown files will be useful for sharing information within my lab. We meet weekly and someone usually shares a new skill they learned, a resource helpful to the group, or we discuss a paper that is relevant to us all. I think using an rmd file to teach new tricks in r, with helpful informational text not stuck behind the usual # symbol required to make notes in an r file, will make for excellent educational opportunities.