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

01

What is inside RMarkdown in more detail?

1 / 14

?

How does R Markdown work - what do you think?

  1. 🤷

  2. I press knit, a document appears, and I believe that anything happening in between could be actual magic.

  3. knitr executes the code and converts .Rmd to .md; Pandoc renders the .md file to the output format you want.

2 / 14

?

How does R Markdown work - answers?

  1. 🤷 (✔️)

  2. "I press knit, a document appears, and I believe that anything happening in between could be actual magic." (🧙‍♂️)

  3. knitr executes the code and converts .Rmd to .md; Pandoc renders the .md file to the output format you want. (✔️)

3 / 14

Metadata

1

4 / 14

Metadata - YAML

"YAML Ain't Markup Language"

---
key: value
---

Drawing of the back of a conductor

5 / 14

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.

Output options

6 / 14

Save output options in your YAML

Basic YAML

---
title: The Great British Bake Off
output: html_document
---
7 / 14

Save output options in your YAML

Basic YAML

---
title: The Great British Bake Off
output: html_document
---

Add html related options

---
title: The Great British Bake Off
output:
html_document:
toc: true
---
7 / 14

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

  2. 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
8 / 14

Answers

---
title: The Great British Bake Off
output:
html_document:
toc: true
toc_float: true
theme: flatly
code_download: true
---
9 / 14

Copying the code to MS Teams to share will lose the formatting!

Parameters

2

10 / 14

Parameters

---
title: The Great British Bake Off
output:
html_document:
toc: true
toc_float: true
theme: flatly
code_download: true
params:
series: '1'
---
11 / 14

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.

Your turn

Change this:

---
title: The Great British Bake Off
output:
html_document:
toc: true
toc_float: true
theme: flatly
code_download: true
params:
series: '1'
---

To this:

---
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
12 / 14

Time for a break!

10:00
13 / 14

Next section...

14 / 14

?

How does R Markdown work - what do you think?

  1. 🤷

  2. I press knit, a document appears, and I believe that anything happening in between could be actual magic.

  3. knitr executes the code and converts .Rmd to .md; Pandoc renders the .md file to the output format you want.

2 / 14
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