4 Week 4 : R markdown

4.1 What is R markdown documents?

  • An R markdown document (a file with the extension .Rmd) allows us to create a report in a variety of formats (e.g., html, pdf, word, slides, interactive documents) that includes your codes, results, and texts.

  • An R markdown document is a plain text file with special formatting characters (i.e., Pandoc’s Markdown).

  • When you render an R markdown document using the render() function,

    • knitr executes all code chunks in an R markdown document to create a new markdown document (a file with the extension .md), and
    • pandoc (a universal document converter) converts a markdown document to the final format.

Rendering R markdown Document

  • An R markdown document has the following structure:
    • YAML header
      • YAML includes options for rendering
      • YAML is surrounded by - - -
      • YAML stands for “YAML Ain’t Markup Language”
    • Text
      • Text includes narration formatted with markdown
    • Code chunks
      • Code chunks include R Codes
      • Code chunks are surrounded by ```

4.3 RStudio Projects

4.4 Publish your R markdown Documents