What is R Markdown?

  • markdown is used exclusively for text and formatting
    • Check out the markdown formatting key (my_first_markdown_file.md) for more information on formatting. :)
  • R markdown includes both markdown as well as R code
  • some useful Rmarkdown conventions:
    •  - - - denotes the YAML header
    •  ```{r} denotes R code
    • everything else is markdown
    • click knit to preview the file

How to insert R code

code > insert chunk

print("hello world")
## [1] "hello world"

Customising your document using the YAML header

  • A YAML Header (“Yet Another Markdown Language”) tells you the core details of your document
  • You can customise your YAML header to produce a pdf_document, html_document or word_document
    • nb this can also be done by selecting options in the “knit” dropdown menu
  • be careful with YAML indents and colons
    • sub-items should be started in a new line (with an indent) and NOT directly after the colon
    • it can be directly after the colon if it refers to that item itself (see above YAML header)
  • add a table of contents as toc: true and toc_float: true
  • You can also change the theme of the output. Play around with the below themes!

output:
html_document:
theme: default, cerulean, journal, flatly, darkly, readable, spacelab, united, cosmo, lumen, paper, sandstone, simplex, yet