class: title-slide, center, middle <span class="fa-stack fa-4x"> <i class="fa fa-circle fa-stack-2x" style="color: #ffffffcc;"></i> <strong class="fa-stack-1x" style="color:#e7553c;">01</strong> </span> # What is inside RMarkdown in more detail? --- .left-column[ <span class="fa-stack fa-4x"> <i class="fa fa-circle fa-stack-2x" style="color: #f2e255;"></i> <strong class="fa-stack-1x" style="color: #fff;">?</strong> </span> ] .right-column[ # How does R Markdown work - what do you think? 1. 🤷 1. I press knit, a document appears, and I believe that anything happening in between could be actual magic. 1. `knitr` executes the code and converts `.Rmd` to `.md`; **Pandoc** renders the `.md` file to the output format you want. ] --- class: top .left-column[ <span class="fa-stack fa-4x"> <i class="fa fa-circle fa-stack-2x" style="color: #f2e255;"></i> <strong class="fa-stack-1x" style="color: #fff;">?</strong> </span> ] .right-column[ # How *does* R Markdown work - answers? 1. 🤷 (✔️) 1. ["I press knit, a document appears, and I believe that anything happening in between could be actual magic."](https://twitter.com/allison_horst/status/1070323369600442368?s=20) (🧙♂️) 1. `knitr` executes the code and converts `.Rmd` to `.md`; **Pandoc** renders the `.md` file to the output format you want. (✔️) ] --- class: inverse, center, middle # <center>Metadata</center> <span class="fa-stack fa-4x"> <i class="fa fa-circle fa-stack-2x" style="color: #fff;"></i> <strong class="fa-stack-1x" style="color:#17a2b8;">1 </strong> </span> --- # Metadata - YAML .pull-left[ _"YAML Ain't Markup Language"_ ```yaml --- key: value --- ``` ] .pull-right[ <img src="images/orchestra.jpg" title="Drawing of the back of a conductor" alt="Drawing of the back of a conductor" width="75%" style="display: block; margin: auto;" /> ] ??? Using the {ymlthis} this section renders the "look" of the YAML with the three dashes then `key: value` which is the format used in YAML. --- class: middle, center # Output options --- # Save output options in your YAML .pull-left[ Basic YAML ```yaml --- title: The Great British Bake Off output: html_document --- ``` ] -- .pull-right[ Add html related options ```yaml --- title: The Great British Bake Off output: html_document: toc: true --- ``` ] --- class: your-turn # Your turn ## Add output options to YAML Use `?rmarkdown::html_document` from your R console to find the code to: 1. Add a floating table of contents 1. Add a theme 🧶 **Knit** to HTML to see the output. **If this was easy**, try to embed the `Rmd` source code to download (appears as a button in top right hand of report). _psst...answers on the next slide..._
03
:
00
--- class: your-turn # Answers ```yaml --- title: The Great British Bake Off output: html_document: toc: true toc_float: true theme: flatly code_download: true --- ``` ??? Copying the code to MS Teams to share will lose the formatting! --- class: inverse, center, middle # <center>Parameters</center> <span class="fa-stack fa-4x"> <i class="fa fa-circle fa-stack-2x" style="color: #fff;"></i> <strong class="fa-stack-1x" style="color:#17a2b8;">2 </strong> </span> --- # <center>Parameters</center> ```yaml --- title: The Great British Bake Off output: html_document: toc: true toc_float: true theme: flatly code_download: true params: series: '1' --- ``` ??? Some may be familiar to the concept of parameters from SQL where code use in multiple places later in the script are written at the top so they can be easily changed. This is a particular example of this 'hard coding' of parameters. --- class: your-turn # Your turn .pull-left[ Change this: ```yaml --- title: The Great British Bake Off output: html_document: toc: true toc_float: true theme: flatly code_download: true params: series: '1' --- ``` ] .pull-right[ To this: ```yaml --- title: The Great British Bake Off output: html_document: toc: true toc_float: true theme: flatly code_download: true params: series: '2' --- ``` ] Now click on knit button and pick __"Knit with Parameters."__ How is this different from what you did above? Note: this might appear as a grey box if your VPN/Network has strict security
03
:
00
--- class: middle, center # ⏱ # Time for a break!
10
:
00
--- class: inverse # <center>Next section...</center>