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;">07</strong> </span> # Output formats --- class: middle, center <img src="images/outputs.png" width="50%" /> ??? Built in formats (in the `rmarkdown` package) versus extensions (different packages that extend output formats available to you) --- class: inverse, center, middle # <center>Built-in formats</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> --- class: middle, center <a href="https://rmarkdown.rstudio.com/docs/reference/index.html#section-output-formats" target="_blank"><img src="images/rmdbase-formats.png" title="Screenshot of the short drop down menu for Knit" alt="Screenshot of the short drop down menu for Knit" width="40%" /></a> https://rmarkdown.rstudio.com/docs/reference/index.html#section-output-formats --- class: your-turn # Your turn ## Use a different built-in format .pull-left[ Use the drop-down menu for the 🧶 **Knit** button and try: 1. Knit to Word 1. Knit to PDF 1. Add toc (table of contents) to both ] .pull-right[ <img src="images/knit-dropdown.png" width="60%" style="display: block; margin: auto;" /> ]
02
:
00
--- # <center>Temp check 🌡</center> Do you have new output formats in your YAML? ```yaml --- output: html_document: toc: true word_document: toc: true pdf_document: toc: true --- ``` ??? Notice that when you knit, the respective code is updated in your YAML. Good for reproducibility. --- class: inverse, center, middle # <center>YAML</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>What is hard about YAML?</center> + Indentations matter + Rarely informative error messages + Knowing which output options are relevant for different formats (i.e., Word, PDF, HTML, etc.) + Easy to forget the right `key` + Easy to forget the possible `values` for a given `key` ??? Output options `toc_float = true` works only in html, not in word. New language, not the same as R. [Blog](https://www.apreshill.com/blog/2020-05-how-i-teach-r-markdown/) by Alison Hill for educators but useful for learners too to see the difficulties. --- class: inverse, center, middle # <center>Add-on formats</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;">3 </strong> </span> --- class: your-turn # Your turn ## Use an extension package .pull-left[ 1. Edit your YAML again! Change the `output:` key to only `bookdown::html_document2` 1. Save the document; click on the dropdown 🧶 **Knit** button- what do you notice? 1. 🧶 **Knit** to html_document2. ] .pull-right[ ```yaml --- output: bookdown::html_document2: toc: true toc_float: true theme: flatly --- ``` ]
02
:
00
.footnote[(note: this requires you to install the [`bookdown` package](https://bookdown.org/yihui/bookdown/)) and point 2. RStudio Cloud might need a refresh F5 to update the menu] ??? Running this code in the cloud will prompt an installation of the {bookdown} package which is very quick to load --- class: inverse # <center>Next section...</center>