class: inverse <img src="ymlthis_title_slide_oc.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- <img src="rmarkdown_wizards.png" width="100%" height="100%" style="display: block; margin: auto;" /> .pull-right[Artwork by @allison_horst] --- class: middle <img src="rmarkdownflow.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- <img src="yml_sources.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- ## *Even the creator of R Markdown and knitr isn't crazy about YAML* <img src="yihui_tweet.png" width="75%" height="75%" style="display: block; margin: auto;" /> --- class: inverse, middle, center # *YAML:* # **Yet Another Markup Language** # **YAML Ain't Markup Language** --- <img src="ymlthis_yaml_example.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- <img src="ymlthis_yaml_example_noted.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- <img src="ymlthis_yaml_example_noted2.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- <img src="ymlthis_yaml_example_noted3.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- <img src="yaml_example_noted4.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- ```text library(ymlthis) as_yml( "title: Annual Report author: Malcolm Barrett date: '`r Sys.Date()`' output: pdf_document: toc: true " ) %>% draw_yml_tree() ``` --- ```text library(ymlthis) as_yml( "title: Annual Report author: Malcolm Barrett date: '`r Sys.Date()`' output: pdf_document: toc: true " *) %>% draw_yml_tree() ``` --- ```text library(ymlthis) as_yml( "title: Annual Report author: Malcolm Barrett date: '`r Sys.Date()`' output: pdf_document: toc: true " ) %>% draw_yml_tree() ``` ``` ├── title: Annual Report ├── author: Malcolm Barrett ├── date: '`r Sys.Date()`' *└── output: * └── pdf_document: * └── toc: true ``` --- class: center, inverse ## ⚠️ **YAML fails silently** <img src="https://media.giphy.com/media/2gcmmuaqnfMt2/giphy.gif" width="75%" height="75%" style="display: block; margin: auto;" /> --- # Introducing ymlthis --- # Introducing ymlthis ## ✔️ **Write YAML** --- # Introducing ymlthis ## ~~✔️ Write YAML~~ ## ✔️ **Document YAML** --- # Introducing ymlthis ## ~~✔️ Write YAML~~ ## ~~✔️ Document YAML~~ ## ✔️ **Improve R Markdown Workflows** --- # Introducing ymlthis ## ~~✔️ Write YAML~~ ## ~~✔️ Document YAML~~ ## ~~✔️ Improve R Markdown Workflows~~ ## 📥 **Validation** --- # Writing YAML ```text yml() ``` --- # Writing YAML ```text yml() ``` ``` --- author: Malcolm Barrett date: '`r format(Sys.Date())`' --- ``` --- # Writing YAML ```text yml() %>% * yml_output( * pdf_document(toc = TRUE), html_document() ) ``` --- # Writing YAML ```text yml() %>% * yml_output( * pdf_document(toc = TRUE), html_document() ) ``` ``` --- author: Malcolm Barrett date: '`r format(Sys.Date())`' *output: * pdf_document: * toc: true html_document: default --- ``` --- # Writing YAML ```text yml() %>% * yml_author( * c("Yihui Xie", "Hadley Wickham"), * affiliation = "RStudio" ) %>% yml_date("07/04/2019") %>% yml_title("Reproducible Research in R") %>% * yml_category(c("r", "reprodicibility")) %>% yml_output( pdf_document( keep_tex = TRUE, includes = includes2(after_body = "footer.tex") ) ) %>% * yml_latex_opts(biblio_style = "apalike") ``` --- # Writing YAML ``` --- author: *- name: Yihui Xie * affiliation: RStudio *- name: Hadley Wickham * affiliation: RStudio date: 07/04/2019 title: Reproducible Research in R *category: *- r *- reprodicibility output: pdf_document: keep_tex: true includes: after_body: footer.tex *biblio-style: apalike --- ``` --- class: center, middle # R Markdown Extensions .large[ | package| output function | top-level YAML | |--:|--:|--:| | bookdown | <span style='color:green'>✓</span> | <span style='color:green'>✓</span> | | blogdown | <span style='color:green'>✓</span> | <span style='color:green'>✓</span> | | pkgdown | <span style='color:green'>✓</span> | <span style='color:green'>✓</span> | | pagedown | <span style='color:green'>✓</span> | <span style='color:green'>✓</span> | | rticles | <span style='color:green'>✓</span> | <span style='color:green'>✓</span> | | distill | <span style='color:green'>✓</span> | <span style='color:green'>✓</span> | | learnr | <span style='color:green'>✓</span> | <span style='color:red'>✗</span>| | xaringan | <span style='color:green'>✓</span> | <span style='color:red'>✗</span>| | revealjs | <span style='color:green'>✓</span> | <span style='color:red'>✗</span>| | flexdashboard | <span style='color:green'>✓</span> | <span style='color:red'>✗</span>| ] --- # Documenting YAML ## ?`yml_*()` --- <img src="ymlthis_fieldguide.jpeg" width="85%" height="85%" style="display: block; margin: auto;" /> .pull-right[Image by @dataandme] --- <img src="https://i.imgur.com/BkzGueG.gif" width="60%" height="60%" style="display: block; margin: auto;" /> --- # Improving R Markdown Workflows ## `use_yml()` ```text yml() %>% use_yml() ``` ``` --- author: Malcolm Barrett date: '`r format(Sys.Date())`' --- ● Paste into R Markdown or YAML file ``` ```text # Places YAML on your cliboard ``` --- # Improving R Markdown Workflows ## `use_rmarkdown()` ```text yml() %>% use_rmarkdown() # opens a new R Markdown file ``` --- # Improving R Markdown Workflows ```text bookdown_yaml <- yml() %>% yml_output(bookdown::pdf_document2()) *use_yml_defaults(bookdown_yaml) ``` --- # Improving R Markdown Workflows ```text bookdown_yaml <- yml() %>% yml_output(bookdown::pdf_document2()) use_yml_defaults(bookdown_yaml) ``` ``` * options(ymlthis.default_yml = "author: Malcolm Barrett * date: '`r format(Sys.Date())`' * output: bookdown::pdf_document2") ● Run interactively or paste into .Rprofile (perhaps using `usethis::edit_r_profile()`) ``` --- # Improving R Markdown Workflows ```text bookdown_yaml <- yml() %>% yml_output(bookdown::pdf_document2()) use_yml_defaults(bookdown_yaml) ``` ``` options(ymlthis.default_yml = "author: Malcolm Barrett date: '`r format(Sys.Date())`' output: bookdown::pdf_document2") ● Run interactively or paste into .Rprofile (perhaps using `usethis::edit_r_profile()`) ``` ```text *use_rmarkdown() ``` --- ### Write to `.Rmd` files | function | action | |--:|--:| | `use_rmarkdown()` | Write `yml` to a `.Rmd` file | | `use_index_rmd()` | Write `yml` to `Index.Rmd` | ### Write to `.yml` files | function | action | |--:|--:| | `use_yml_file()` | Write `yml` to a file | | `use_bookdown_yml()`| Write `yml` to `_bookdown.yml` | | `use_navbar_yml()` | Write `yml` to `_navbar.yml` | | `use_output_yml()` | Write `yml` to `_output.yml` | | `use_pkgdown_yml()` | Write `yml` to `_pkgdown.yml` | | `use_site_yml()` | Write `yml` to `_site.yml` | --- class: inverse, center, middle # visit the site for tutorials and documentation # [**http://ymlthis.r-lib.org**](http://ymlthis.r-lib.org) --- class: inverse, center, middle  ###
[malcolmbarrett](https://github.com/malcolmbarrett/) ###
[@malco_barrett](https://twitter.com/malco_barrett) Slides created via the R package [xaringan](https://github.com/yihui/xaringan).