-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.Rmd
662 lines (484 loc) · 10.4 KB
/
index.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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
---
title: "How to Make Slides in R"
subtitle: "Using xaringan"
author: "Zhi Yang"
date: "2019/2/26"
output:
xaringan::moon_reader:
css: ["default", "rladies","lucy-fonts", "my-style.css"]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
#chakra: "remark.js"
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(tidy = FALSE, tidy.opts=list(width.cutoff=40))
library(babynames)
library(tidyverse)
```
# How I met xaringan <img src="imgs/icon.png" alt="Sharingan" width="10%" align="center"/>
.center[An `R` user who would like to share awesome things in `R`]
--
.pull-left[
by showing a bunch of `R code snippets` without losing taste.
<img src="https://i2.wp.com/erickimphotography.com/blog/wp-content/uploads/2018/09/steve-jobs-interview-11.png" width="90%" />
]
--
.pull-right[
given no time nor money on formatting codes and adjusting layouts.
<img src="https://cdn-images-1.medium.com/max/800/1*8Z1xFlBtHVN1rY7oWFnlIg.gif"/>
]
???
https://medium.com/@jakeout/deprecate-keynote-78f0f09424dd
---
# Meet xaringan <img src="imgs/icon.png" alt="Sharingan" width="10%" align="center"/>
Beautiful and concise layout
.center[<img src=imgs/ml.gif width="47%"> <img src=imgs/showcase.gif width="47%">]
.center[<img src=imgs/du.gif width="47%">]
---
# Meet xaringan <img src="imgs/icon.png" alt="Sharingan" width="10%" align="center"/>
Code highlighting and live demos
.center[![](imgs/ggplot2.gif)]
---
# Meet xaringan <img src="imgs/icon.png" alt="Sharingan" width="10%" align="center"/>
Version control and easy distribution
.center[
<img src=https://marketplace-cdn.atlassian.com/files/images/cec44feb-0b1b-4fe3-936d-67a51a1fe28e.png width="50%">
<img src=https://doconfig.netlify.com/images/logos/netlify.jpg width="50%") />
]
---
# Meet xaringan <img src="imgs/icon.png" alt="Sharingan" width="10%" align="center"/>
It animates
.center[![](https://www.garrickadenbuie.com/images/2018/animated-xaringan-slides/xaringan-animated.gif)
]
---
# Infinite moon reader `r emo::ji("astronaut")`
Do you use `ctrl + K` to render your slides?
- So, Are you tired from scrolling down to the page you were working on?
.center[<img src="https://memegenerator.net/img/instances/61114187.jpg" width='50%' align="middle"/>]
--
####Turn on the `Moon Reader` from either the pacakge or the addins
####From now on, the slides will auto-reload every time you `save` it
---
# Infinite moon reader `r emo::ji("astronaut")`
.center[![](https://user-images.githubusercontent.com/163582/53144527-35f7a500-3562-11e9-862e-892d3fd7036d.gif)]
---
class: center, middle
# Keyboard shortcuts
Press `h` or `?`
--
`m` -> mirror
`b` -> blackout
`f` -> fullscreen mode
--
`c` -> clone slideshow
`p` -> presenter mode
`t` -> restart timer
---
# Themes
- Built-in themes
```{r eval=TRUE}
names(xaringan:::list_css())
```
--
These go to your YAML
```{r eval = FALSE}
output:
xaringan::moon_reader:
css: [default, rladies, rladies-fonts] #<<
```
---
class: center, middle
# Build your own theme
<img src="imgs/dark.jpg" width=80% align="center" />
<img src="imgs/light.jpg" width=80% align="center" />
https://pkg.garrickadenbuie.com/xaringanthemer/
---
# Somewhere in the middle?
Add `my-style.css` to the YAML with the current css file
```{r eval = FALSE}
output:
xaringan::moon_reader:
css: [default, rladies, lucy-fonts, my-style.css] #<<
```
--
While sitting in my-style.css file,
```css
.red { color: red; }
.remark-code-line-highlighted { background-color: #e8c9e9; }
.remark-code, .remark-inline-code {
color: #7c347f;
font-weight: 300;
}
```
--
I've changed it to .red[red].
---
# Where to find the themes files?
You can find CSS files here. However, don't save your own CSS file here.
.center[![](/imgs/themelibs.PNG)]
--
### - start with an existing theme
### - try change something and see what happens
---
# Meet slidex
It converts PowerPoint slides to xaringan slides
.center[![](https://github.com/datalorax/slidex/raw/master/docs/slidex-preview.gif)]
---
#Start with the YAML
.pull-left[
### Simple version
```
---
title: "How to Make Slides in R"
output:
xaringan::moon_reader
---
```
]
--
.pull-right[
### More options
```
---
title: "How to Make Slides in R"
subtitle: "Using xaringan"
author: "Zhi Yang"
date: "2019/2/26"
output:
xaringan::moon_reader:
css: ["default", "rladies",
"lucy-fonts",
"my-style.css"]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
#chakra: "remark.js"
---
```
]
---
# Make new slides
Three dashes `---` gives a new slide
```
---
title: "How to Make Slides in R"
output:
xaringan::moon_reader
---
A slide
---
Another slide
```
---
# Align an entire slide
.left-column[
###Horizontal
```
left,
*center,
right
```
###Vertical
```
top,
*middle,
bottom
```
]
.right-column[
```r
---
*class: center, middle
# Demo slide
This is a center- and middle- aligned slide.
```
]
---
# Align the text
.left-column[
###Horizontal
```
.left[texts]
*.center[texts]
.right[texts]
```
]
.right-column[
```r
---
class: center, middle
# Demo slide
*.right[This is a center- and middle- aligned slide.]
```
]
---
class: center, middle
# Demo slide
.right[This is a center- and middle- aligned slide.]
---
# Incremental reveals
.left-column[
```markdown
# Hi
Did you know
--
you can
--
do this?
```
]
#Hi
--
Did you know
--
you can
--
do this?
---
# Code and higtlight
use the trailing comment `#<<` to highlight specific lines of the code
.pull-left[
Source:
````markdown
`r ''````{r}
namedata <- babynames %>%
filter(name == "Orange") %>%
filter(sex == "M") %>% #<<
arrange(year)
head(namedata)
```
````
]
.pull-right[
Output:
```{r eval=FALSE}
namedata <- babynames %>%
filter(name == "Orange") %>%
filter(sex == "M") %>% #<<
arrange(year)
head(namedata)
```
]
---
# Output and higtlight
use the chunk option `highlight.output` to highlight specific lines of the text output
.pull-left[
Source:
````markdown
`r ''````{r head, highlight.output=c(1, 3)}
namedata <- babynames %>%
filter(name == "Orange") %>%
filter(sex == "M") %>% #<<
arrange(year)
head(namedata)
```
````
]
.pull-right[
Output:
```{r, highlight.output=c(1, 3), echo=FALSE}
namedata <- babynames %>%
filter(name == "Orange") %>%
filter(sex == "M") %>% #<<
arrange(year)
head(namedata)
```
]
---
# Two-columns
.top-column[
````md
.pull-left[
`r ''````{r refname echo=TRUE, eval=FALSE}
your R code
```
]
.pull-right[
`r ''````{r ref.label="refname" echo=FALSE, eval=TRUE}
```
]
````
]
`.pull-left` and `.pull-right` provide 47% width
--
.pull-left[
```{r babynames, eacho=TRUE, eval=FALSE}
namedata <- babynames %>%
filter(name == "Orange") %>%
filter(sex == "M") %>% #<<
arrange(year)
head(namedata)
```
]
--
.pull-right[
```{r, ref.label="babynames", echo=FALSE, eval=TRUE}
```
]
---
# Two-columns
````md
.left-column[
`r ''````{r evel = FALSE}
Your R code
```
]
.right-column[
`r ''````{r evel = FALSE, echo = FALSE}
Your R code
```
]
````
`.left-column` and `.right-column` provide 20% and 75% width
--
.left-column[
<img src="https://pbs.twimg.com/media/C8IFatuU0AAO-xc.jpg" align="center" />
```r
head(gss_cat)
```
]
--
.right-column[
```{r echo=FALSE, eval=TRUE}
head(gss_cat)
```
]
---
#Add a table
```{r eval=TRUE}
head(iris, n = 3)
knitr::kable(head(iris, n = 3), format = "html")
```
Set the table to be the `HTML` format
---
#Add a plot
````{r eval=TRUE, fig.height = 5, fig.width = 5}
par(mar = c(4, 4, 1, 0.1))
plot(cars, pch = 19, col = "darkgray", las = 1)
```
use `fig.height` and `fig.width` to control the size
---
#Add an image
```r
![](/imgs/ocrug.jpeg)
```
![](/imgs/ocrug.jpeg)
---
#Resize it
Should it be something like `![](/imgs/ocrug.jpeg){width=10px}` ? `r emo::ji("cry")`
--
Option 1:
```markdown
<img src="imgs/ocrug.jpeg" width="20%" />
```
<img src="imgs/ocrug.jpeg" width="20%" />
--
Option 2:
````markdown
`r ''````{r out.width = "20%", eval=TRUE}
knitr::include_graphics("imgs/ocrug.jpeg")
```
````
```{r out.width = "20%", echo=FALSE, eval=TRUE}
knitr::include_graphics("imgs/ocrug.jpeg")
```
---
background-image: url(/imgs/ocrug.jpeg)
background-size: cover
# Full screen
```r
background-image: url(/imgs/ocrug.jpeg)
background-size: cover
```
---
background-image: url(/imgs/ocrug.jpeg)
background-size: contain
# Rescale only
```r
background-image: url(/imgs/ocrug.jpeg)
background-size: contain
```
---
background-image: url(/imgs/ocrug.jpeg)
background-size: contain
background-position: bottom
# Change position
```r
background-image: url(/imgs/ocrug.jpeg)
background-size: contain
background-position: bottom
```
---
background-image: url(https://secure.meetupstatic.com/photos/event/2/b/9/e/600_471491166.jpeg)
background-size: contain
background-position: bottom
# Use online image
```markdown
background-image: url(https://secure.meetupstatic.com/photos/event/2/b/9/e/600_471491166.jpeg)
background-size: contain
background-position: bottom
```
---
background-image: url(imgs/ocrug_logo.png), url(imgs/ocrug_logo.png)
background-position: 0% 100%, 100% 0%
background-size: 30%, 10%
# Logos
```markdown
background-image: url(imgs/ocrug_logo.png), url(imgs/ocrug_logo.png)
background-position: 0% 100%, 100% 0%
background-size: 30%, 10%
```
---
# Hosting slides `r fontawesome::fa("github")`
.center[<img src="imgs/github.png" width="80%" />]
---
# Netlify `r emo::ji("computer")`
.pull-left[
`Step 1:` go to netlify.com
<img src="imgs/netlify.jpg" align="middle" />
]
.pull-right[
`Step 2:` connect with your Github account
<img src="imgs/step2.jpg" align="middle" />
]
---
# Netlify `r emo::ji("computer")`
.pull-left[
`Step 3:` select a repo
<img src="imgs/step3.jpg" align="middle" />
]
--
.pull-right[
`Step 4:` select a branch
<img src="imgs/step4.jpg" align="middle" />
]
---
# Netlify `r emo::ji("computer")`
.pull-top[
`Step 5:` deploy a site
<img src="imgs/deploy.jpg" width='60%' align="middle" />
]
.pull-bottom[
`Step 6:` change site name
<img src="imgs/step5.jpg" width='50%' align="middle" />
]
---
class: middle
# More info...
.pull-left[![](/imgs/gh1.png)]
.pull-right[![](/imgs/gh2.png)]
---
class: center, middle
# Thanks!
<br>
@zhiiiyang
https://github.com/zhiiiyang/XaringanTutorial
<br>
Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan)
Template created by [Alison Hill](https://alison.rbind.io/)