What is RMarkdo w n ? C OMMU N IC ATIN G W ITH DATA IN TH E - - PowerPoint PPT Presentation

what is rmarkdo w n
SMART_READER_LITE
LIVE PREVIEW

What is RMarkdo w n ? C OMMU N IC ATIN G W ITH DATA IN TH E - - PowerPoint PPT Presentation

What is RMarkdo w n ? C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE Timo Grossenbacher Data Jo u rnalist What y o u ha v e done so far ... loaded the necessar y libraries ... preprocessed the data w ith mutate() and filter() ... de ned


slide-1
SLIDE 1

What is RMarkdown?

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

Timo Grossenbacher

Data Journalist

slide-2
SLIDE 2

COMMUNICATING WITH DATA IN THE TIDYVERSE

What you have done so far

...loaded the necessary libraries ...preprocessed the data with mutate() and filter() ...dened a custom theme ...created a dot plot ...polished that plot and made it t for mobile screens

slide-3
SLIDE 3

COMMUNICATING WITH DATA IN THE TIDYVERSE Taken from rmarkdown.rstudio.com (hp://rmarkdown.rstudio.com/images/RMarkdownOutputFormats.png)

1

slide-4
SLIDE 4

COMMUNICATING WITH DATA IN THE TIDYVERSE

slide-5
SLIDE 5

COMMUNICATING WITH DATA IN THE TIDYVERSE

Behind the scenes

R for Data Science (hp://r4ds.had.co.nz/r-markdown.html)

1

slide-6
SLIDE 6

COMMUNICATING WITH DATA IN THE TIDYVERSE

Reproducibility

Advantages

  • thers can reproduce and question your work

you can automate your workow Prerequisites the code needs to be executable the data needs to be provided or at least linked to (the soware environment needs to be known)

slide-7
SLIDE 7

Let's practice!

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

slide-8
SLIDE 8

Formatting with Markdown

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

Timo Grossenbacher

Data Journalist

slide-9
SLIDE 9

COMMUNICATING WITH DATA IN THE TIDYVERSE

Markdown

Markdown was created in 2004 by John Gruber, with the goal of of enabling people "to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML".

Daringreball.net (hps://web.archive.org/web/20040402182332/hp://daringreball.net/projects/markdown/)

1

slide-10
SLIDE 10

COMMUNICATING WITH DATA IN THE TIDYVERSE

Markdown

# A short text ## Introduction Hello, *my name* is **Timo Grossenbacher** and I work at [SRF Data](https://srf.ch/data).

A short text

Introduction

Hello, my name is Timo Grossenbacher and I work at SRF Data.

<h1>A short text</h1> <h2>Introduction</h2> Hello, <em>my name</em> is <strong>Timo Grossenbacher</strong> and I work at <a href = "https://srf.ch/data"> SRF Data</a>.

slide-11
SLIDE 11

COMMUNICATING WITH DATA IN THE TIDYVERSE

Pandoc Markdown

RMarkdown = Markdown prose + R code For all formaing options see the Pandoc Markdown Reference

slide-12
SLIDE 12

Let's put this into practice!

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

slide-13
SLIDE 13

R code in RMarkdown documents

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

Timo Grossenbacher

Data Journalist

slide-14
SLIDE 14

COMMUNICATING WITH DATA IN THE TIDYVERSE

slide-15
SLIDE 15

COMMUNICATING WITH DATA IN THE TIDYVERSE

Adding R chunks

```{r} x <- 2 + 2 x ```

4

2 plus 2 equals `r 2 + 2`.

2 plus 2 equals 4.

slide-16
SLIDE 16

COMMUNICATING WITH DATA IN THE TIDYVERSE

The `knitr` package

R for Data Science (hp://r4ds.had.co.nz/r-markdown.html)

1

slide-17
SLIDE 17

COMMUNICATING WITH DATA IN THE TIDYVERSE

R chunk options

```{r include=FALSE} x <- 2 + 2 x ``` ```{r} x ```

4

slide-18
SLIDE 18

COMMUNICATING WITH DATA IN THE TIDYVERSE

More R chunk options

Option Eect

include

Whether to show the R code chunk and its output.

echo

Whether to show the R code chunk.

message

Whether to show output messages.

warning

Whether to show output warnings.

eval

Whether to actually evaluate the R code chunk. More options on the respective help page of the knitr package.

slide-19
SLIDE 19

Let's try this out!

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

slide-20
SLIDE 20

Images in RMarkdown files

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE

Timo Grossenbacher

Data Journalist

slide-21
SLIDE 21

COMMUNICATING WITH DATA IN THE TIDYVERSE

slide-22
SLIDE 22

COMMUNICATING WITH DATA IN THE TIDYVERSE

Adjusting figure options in RMarkdown

```{r} ... ggplot2 code ... ```

slide-23
SLIDE 23

COMMUNICATING WITH DATA IN THE TIDYVERSE

Adjusting figure options in RMarkdown

```{r fig.height = 6} ... ggplot2 code ... ```

slide-24
SLIDE 24

COMMUNICATING WITH DATA IN THE TIDYVERSE

Figure options

Option Possible values Eect

fig.height

Numeric, inches The height of the image in inches.

fig.width

Numeric, inches The width of the image in inches.

fig.align

One of "le", "right" or "center" The alignment of the image in the report. More options on the respective help page of the knitr package.

slide-25
SLIDE 25

COMMUNICATING WITH DATA IN THE TIDYVERSE

External images in RMarkdown reports

![An impressive mountain](https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/ Matterhorn_from_Domh%C3%BCtte_-_2.jpg/1200px-Matterhorn_from_Domh%C3%BCtte_-_2.jpg)

An impressive mountain

slide-26
SLIDE 26

Let's practice!

C OMMU N IC ATIN G W ITH DATA IN TH E TIDYVE R SE