Skip to main content

Section B.1 Introduction

Throughout this book, we have been writing R code in separate R scripts. This is great when we are writing code for ourselves. However, this entire book has been centered around reproducibility. An R script can be reproducible, but is limited in how well it communicates results, narrative, and output together in a single place. Sure, you can add comments to help explain what the code is doing, but it does not allow for much text. It also doesn’t show outputs, whether that’s visuals or numbers.
This is exactly where R Markdown comes into play. With R Markdown, you are able to:
  • Write code just as you would in an R script
  • Have dedicated spaces for text
  • Show outputs for numbers and visuals
  • Share with people outside of the R environment
In fact, this entire book was written using R Markdown! Each chapter is a different R Markdown file all put together.
In this chapter, we are going to go through the benefits of R Markdown and how to properly utilize it.