-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsession1.Rmd
466 lines (299 loc) · 8.6 KB
/
session1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
---
title: "Communicating with Data via R markdown"
subtitle: "R Markdown Basics"
author: "Emi Tanaka"
email: "dr.emi.tanaka@gmail.com"
date: "4th October 2019 | COMBINE | Sydney, Australia"
length: "25 minutes"
pdflink: "session1.pdf"
titleslide_bgimg: "images/bg2.jpg"
color_theme: "white"
output:
xaringan::moon_reader:
css: [ninjutsu, "assets/animate.css", "assets/cssgrid.css", "assets/custom.css"]
self_contained: false # if true, fonts will be stored locally
seal: false # show a title slide with YAML information
#yolo: false # show Karl randomly
chakra: 'libs/remark-latest.min.js'
beforeInit: "assets/custom.js"
lib_dir: libs
includes:
in_header: "assets/custom.html"
# before_body:
after_body: "assets/remarkjs_extended.html"
# includes
mathjax: "assets/mathjax-local/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
nature:
# autoplay: 100 # in milliseconds to play next slide
# coundown: 100 # to display on each slide (TRUE if autoplay on)
# titleSlideClass: c("center", "middle", "inverse")
highlightStyle: dark # [arta, ascetic, dark, default, far, github, googlecode, idea, ir-black, magula, monokai, rainbow, solarized-dark, solarized-light, sunburst, tomorrow, tomorrow-night-blue, tomorrow-night-bright, tomorrow-night, tomorrow-night-eighties, vs, zenburn.]
highlightLanguage: r # no-highlight to disable
highlightLines: true
highlightSpans: false # true: use `backticks` as delimiters.
countIncrementalSlides: false
slideNumberFormat: '%current%/%total%'
navigation:
scroll: false # disable scrolling to navigate slides
touch: true
click: false
ratio: '16:9' # ['4:3', '13:9']
---
```{r external, child="scripts/setup.Rmd", include=FALSE}
```
```{r titleslide, child="scripts/titleslide.Rmd"}
```
---
class: question
::: {.item text-align:left; }
**Hi! I'm Emi! `r emo::ji("wave")`**
<br>
I'm a .yellow[lecturer in statistics] at The University of Sydney (soon moving to .yellow[Monash University]).
<br>
**Introduce yourself to someone you don't know!**
:::
`r countdown::countdown(3, font_size = "1.3em", color_background="white", color_text = "black", color_border="black")`
---
class: question
# HELP!
<img src="images/sticky-note.png" width="150px"/>
Please send SOS signal by attaching sticky note on your laptop.
<br>
Please help your neighbours `r emo::ji("please")`
---
class: challenge font_smaller middle
Open
<br>
http://bit.ly/rmd-combine-2019
<br>
and save a permanent copy to your RStudio Cloud account.
---
class: center
# Schedule
<br>
| Time | Activity |
|:--------------|:----------------------------------------|
| 1:00PM - 1:25PM | Session 1: R Markdown Basics |
| 1:25PM - 1:30PM | *Break* `r emo::ji("tea")` |
| 1:30PM - 3:00PM | Session 2A: Reproducible Reports I |
| 3:00PM - 3:30PM | *Afternoon Tea* `r paste0(emo::ji("coffee"), emo::ji("cake"))` |
| 3:30PM - 4:10PM | Session 2B: Reproducible Reports II |
| 4:10PM - 4:15PM | *Break* `r emo::ji("toilet")` |
| 4:15PM - 5:00PM | Session 3: Pretty Presentations |
---
# R Markdown Basics
<img src="images/demo-first-rmd.png" width="70%" />
---
# Knitting: <code>Rmd</code> <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> <code>md</code> <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> <code>html</code> <i class="far fa-file"></i>
<img src="images/demo-knit-html.png" width="100%" />
---
# Knitting: <code>Rmd</code> <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> <code>md</code> <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> <code>pdf</code> <i class="far fa-file"></i>
<img src="images/demo-knit-pdf.png" width="100%" />
---
class: middle question
There are many other .yellow[output formats] possible with R Markdown via Pandoc.
Can you name another 3?
---
class: font_small
# R Markdown under the hood: `html_document`
.indigo[`knitr`] `r emo::ji("package")` does the hard work of converting <code>Rmd</code> <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> <code>md</code> <i class="far fa-file"></i>
::: grid
::: item
````markdown
---
title: "My Report"
output: html_document
---
# Hello
`r ''````{r}
1 + 1
```
````
<p></p>
:::
::: item
````markdown
---
title: "My Report"
output: html_document
---
# Hello
`r ''````r
1 + 1
```
`r ''````
## [1] 2
```
````
<p></p>
:::
:::
::: {.pos top:20%;left:20%;}
`Rmd` <i class="far fa-file"></i>
:::
::: {.pos top:20%;left:70%;}
`md` <i class="far fa-file"></i>
:::
---
class: font_small
# R Markdown under the hood: `html_document`
Then .indigo[`rmarkdown`] `r emo::ji("package")` prepares <code>md</code> <i class="far fa-file"></i> for .indigo[`pandoc`] to convert to html <i class="far fa-file"></i>.
::: grid
::: item
````markdown
---
title: "My Report"
output: html_document
---
# Hello
`r ''````r
1 + 1
```
`r ''````
## [1] 2
```
````
<p></p>
:::
::: item
```html
<body>
<div class="container-fluid main-container">
<div class="fluid-row" id="header">
<h1 class="title toc-ignore">My Report</h1>
</div>
<div id="hello" class="section level1">
<h1>Hello</h1>
<pre class="r"><code>1 + 1</code></pre>
<pre><code>## [1] 2</code></pre>
</div>
</div>
</body>
```
:::
:::
::: {.white .font_small .pos bottom:60px; right:10%; width:200px;padding:5px;background-color:rgb(256,160,160, 0.3);border: solid 3px black; }
<i class="fas fa-exclamation-triangle"></i> This html file is missing some elements due to restriction of space.
:::
::: {.pos top:20%;left:20%;}
`md` <i class="far fa-file"></i>
:::
::: {.pos top:20%;left:70%;}
`html` <i class="far fa-file"></i>
:::
---
class: font_small
# R Markdown under the hood: .red[`pdf_document`]
Same as before: `knitr` `r emo::ji("package")` converts <code>Rmd</code> <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> <code>md</code> <i class="far fa-file"></i>
::: grid
::: item
````markdown
---
title: "My Report"
output: pdf_document
---
# Hello
`r ''````{r}
1 + 1
```
````
<p></p>
:::
::: item
````markdown
---
title: "My Report"
output: pdf_document
---
# Hello
`r ''````r
1 + 1
```
`r ''````
## [1] 2
```
````
<p></p>
:::
:::
::: { .pos top:20%;left:20%; }
`Rmd` <i class="far fa-file"></i>
:::
::: { .pos top:20%;left:70%; }
`md` <i class="far fa-file"></i>
:::
---
class: font_small
# R Markdown under the hood: .red[`pdf_document`]
Then `rmarkdown` `r emo::ji("package")` prepares <code>md</code> <i class="far fa-file"></i> for `pandoc` to convert to .indigo[`tex`] <i class="far fa-file"></i> <i class="fas fa-arrow-right"></i> pdf <i class="fas fa-file-pdf"></i>.
::: grid
::: item
````markdown
---
title: "My Report"
output: html_document
---
# Hello
`r ''````r
1 + 1
```
`r ''````
## [1] 2
```
````
<p></p>
:::
::: item
```latex
\begin{document}
\maketitle
\hypertarget{hello}{%
\section{Hello}\label{hello}}
\begin{Shaded}
\begin{Highlighting}[]
\DecValTok{1} \OperatorTok{+}\StringTok{ }\DecValTok{1}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 2
\end{verbatim}
\end{document}
```
:::
:::
::: {.pos top:20%;left:10%;}
`md` <i class="far fa-file"></i>
:::
::: {.pos top:20%;left:40%;}
`tex` <i class="far fa-file"></i>
:::
::: {.white .font_small .pos bottom:7%; right:10%; width:200px;padding:5px;background-color:rgb(256,160,160, 0.3);border: solid 3px black; }
<i class="fas fa-exclamation-triangle"></i> This tex document is missing elements before `\begin{document}` due to restriction of space.
:::
---
class: challenge middle
#Get started with
`challenge-01.Rmd`
`r countdown::countdown(5, font_size = "1.5em", color_background="white", color_text = "black", color_border="black")`
---
class: challenge middle
# Advanced question
How do you render different output formats at once?
---
```{r checklist, echo = FALSE}
checklist <- c("Make a html document from .Rmd",
"Make a pdf document from .Rmd",
"Have some understanding of how R Markdown works under the hood.",
"Have some understanding of how some R Markdown components works only in specific output formats.")
```
```{r endslide, child="scripts/endslide.Rmd"}
```
```{r, include = FALSE, eval = FALSE}
# not working
# get the following erorr:
#[error] consume error: websocketpp.processor:4 (A message was too large)
pagedown::chrome_print(here::here("slides", "session1.html"),
wait = 10,
format = "pdf",
timeout = 10)
```