+ - 0:00:00
Notes for current slide
Notes for next slide

1 / 38

Artwork by @allison_horst

2 / 38

3 / 38

4 / 38

Even the creator of R Markdown and knitr isn't crazy about YAML

5 / 38

YAML:

Yet Another Markup Language

YAML Ain't Markup Language

6 / 38

7 / 38

8 / 38

9 / 38

10 / 38

11 / 38
library(ymlthis)
as_yml(
"title: Annual Report
author: Malcolm Barrett
date: '`r Sys.Date()`'
output:
pdf_document:
toc: true
"
) %>% draw_yml_tree()
12 / 38
library(ymlthis)
as_yml(
"title: Annual Report
author: Malcolm Barrett
date: '`r Sys.Date()`'
output:
pdf_document:
toc: true
"
) %>% draw_yml_tree()
13 / 38
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
14 / 38

⚠️ YAML fails silently

15 / 38

Introducing ymlthis

16 / 38

Introducing ymlthis

✔️ Write YAML

17 / 38

Introducing ymlthis

✔️ Write YAML

✔️ Document YAML

18 / 38

Introducing ymlthis

✔️ Write YAML

✔️ Document YAML

✔️ Improve R Markdown Workflows

19 / 38

Introducing ymlthis

✔️ Write YAML

✔️ Document YAML

✔️ Improve R Markdown Workflows

📥 Validation

20 / 38

Writing YAML

yml()
21 / 38

Writing YAML

yml()
---
author: Malcolm Barrett
date: '`r format(Sys.Date())`'
---
22 / 38

Writing YAML

yml() %>%
yml_output(
pdf_document(toc = TRUE),
html_document()
)
23 / 38

Writing YAML

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
---
24 / 38

Writing YAML

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")
25 / 38

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
---
26 / 38

R Markdown Extensions

package output function top-level YAML
bookdown
blogdown
pkgdown
pagedown
rticles
distill
learnr
xaringan
revealjs
flexdashboard
27 / 38

Documenting YAML

?yml_*()

28 / 38

Image by @dataandme

29 / 38

30 / 38

Improving R Markdown Workflows

use_yml()

yml() %>%
use_yml()
---
author: Malcolm Barrett
date: '`r format(Sys.Date())`'
---
● Paste into R Markdown or YAML file
# Places YAML on your cliboard
31 / 38

Improving R Markdown Workflows

use_rmarkdown()

yml() %>%
use_rmarkdown()
# opens a new R Markdown file
32 / 38

Improving R Markdown Workflows

bookdown_yaml <- yml() %>% yml_output(bookdown::pdf_document2())
use_yml_defaults(bookdown_yaml)
33 / 38

Improving R Markdown Workflows

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()`)
34 / 38

Improving R Markdown Workflows

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()`)
use_rmarkdown()
35 / 38

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
36 / 38

visit the site for tutorials and documentation

http://ymlthis.r-lib.org

37 / 38

malcolmbarrett

@malco_barrett

Slides created via the R package xaringan.

38 / 38

Artwork by @allison_horst

2 / 38
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow