R Markdown Introduction


R Markdown is a authoring framework that allows for reproducible documentation of data science within the context of R Studio. This is an introduction designed to teach you how to use R Markdown in a few minutes. Further info and some of the examples used below can be found here: http://rmarkdown.rstudio.com


R Markdown allows you to incorporate text, inline code, code chunks, and results into a single document. You can then create html pages, pdfs, word docs, and other file formats discussed below.

Using R Markdown


To install R Markdown, you can navigate to tools -> install packages -> rmarkdown in R Studio. Alternatively, you can run the console command: install.packages(“rmarkdown”)

Creating a File

To create a new R Markdown file, go to file -> New File -> R Markdown. There, you can create a blank file or choose a template. R Markdown files are plain text files with the .Rmd extension. If this is your first time using R Markdown, we suggest using the .html template by entering a Title and Author Name and clicking Ok.

The first few lines of every R Markdown file make up a YAML header enclosed by three “-“s on each end. If you created a new file from above, you will see that your header contains the title, author, date, and output. Other document settings can also be modified in the header, but these will be discussed later.

Text Formatting Tips

Text written in R Markdown uses the Markdown syntax. There are a number of annotations that will result in formatted text upon file rendering. A helpful reference guide can be found here and can be accessed by going to Help -> Markdown Quick Reference
Below are some formatting examples that you can try. You can preview using the Knit button in the toolbar, which will be discussed in further detail below.
*italic* or _italic_
**bold** or __bold__
superscript^2^ and subscript~2~
code blocks can be made with “``”

line breaks require two or more spaces at the end of the line
links: [text for link](www.rstudio.com)
# Example Header for largest header, add more # for smaller headers. Note: you must include the space after the # or it will not format correctly
For further syntax tips (including lists, images, etc…), take a look at the reference documents linked above.

Code Chunks

You can incorporate code chunks into your R Markdown files using:

  • The button in the toolbar
  • Ctrl + Alt + I (OS X: Cmd + Option +I)
  • Chunk delimiters like below


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The source code is licensed under MIT.

Suggest changes

If you find any mistakes (including typos) or want to suggest changes, please feel free to edit the source file of this page on Github and create a pull request.


For attribution, please cite this work as

Ian Waters (2020). Using R_Markdown. ImLab Notes. /post/2020/07/08/using-r-markdown/

BibTeX citation

  title = "Using R_Markdown",
  author = "Ian Waters",
  year = "2020",
  journal = "ImLab Notes",
  note = "/post/2020/07/08/using-r-markdown/"