-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathS1.Rmd
732 lines (452 loc) · 13.4 KB
/
S1.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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
---
title: "Doing statistical and non-statistical things using R without tears"
subtitle: "Session 1"
author: "Caroline Gao "
output:
xaringan::moon_reader:
css:
- xaringan-themer.css
- "assets/presentation.css"
- "assets/fonts.css"
- "assets/tachyons-addon.css"
- "assets/font-awesome-all.css"
- "assets/animate.css"
nature:
slideNumberFormat: "%current%"
highlightStyle: github
highlightLines: true
ratio: 16:9
countIncrementalSlides: true
---
background-image: url(https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg)
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(xaringanthemer)
#xaringan::inf_mr()
style_duo_accent(primary_color = "#1381B0",
secondary_color = "#4a4947",
link_color= "#009E73",
code_inline_font_size = "2em",
colors = c(
red = "#f34213",
pink ="#CC79A7",
purple = "#BBA9E2",
orange = "#ff8811",
green = "#009E73",
white = "#FFFFFF"))
library(knitr)
library(fontawesome)
library(tidyverse)
library(GGally)
library(plotly)
```
???
Image credit: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Sharingan_triple.svg)
---
class: center, middle
# Welcome to the new programming world
<iframe width="800" height="440" src="https://www.youtube.com/embed/Ru5fQZ714x8?controls=0&start=2" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
---
class: inverse, center, middle
## “Learning to write programs stretches your mind, and helps you think better, creates a way of thinking about things that I think is helpful in all domains.” - Bill Gates
---
# How to get started
--
- Choose a program most relevant to you study or work
--
- Install it on your computer
--
- Start using it in anything you can think of (even as a calculator)
--
- Then...
--
- `r emo::ji("rocket")` `r emo::ji("rocket")` `r emo::ji("rocket")`
---
# Important things to consider
- Which program package is most relevant to your work and study
--
- How strong are your motivations
--
- Level of support you have to learn and use the program
--
- The cost-effectiveness of learning should never be a concern
---
## Why use R ?
```{r,echo=FALSE,out.width="80%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/R_illustration.jpg")
```
---
.flex[
.w-50.center[
```{r,echo=FALSE,out.width="95%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/R ranking.png")
```
]
.w-50.center[
```{r,echo=FALSE,out.width="100%"}
# All defaults
knitr::include_graphics("graphics/R_research.png")
```
]
]
---
class: inverse, center, middle
## Practically, you can
--
## **.purple[efficiently]** achieve almost **.purple[everything]** using R
--
## in research
--
## with assistance from other tools
---
## Study design
Experimental design (e.g, experiments, dose-response studies, clinical trails etc.)
Power calculation and sample size estimation
Random allocation, matching and simulation
.small[[CRAN Task View: Design of Experiments (DoE) & Analysis of Experimental Data](https://cran.r-project.org/web/views/ExperimentalDesign.html)]
.small[[CRAN Task View: Clinical Trial Design, Monitoring, and Analysis](https://cran.r-project.org/web/views/ClinicalTrials.html)]
---
```{r,echo=FALSE,out.width="80%"}
# All defaults
knitr::include_graphics("graphics/Shiny CRT.png")
```
.small[https://clusterrcts.shinyapps.io/rshinyapp/]
---
## Systematic review
.flex[
.w-80[
```{r,echo=FALSE,out.width="100%"}
# All defaults
knitr::include_graphics("graphics/reviews.png")
```
```{r,echo=FALSE,out.width="70%"}
# All defaults
knitr::include_graphics("graphics/Metagear.png")
```
]
.w-20.center[
<br> <br>
.small[ [revtools](https://revtools.net/screening.html#manual-screening)]
<br> <br> <br> <br> <br> <br>
.small[ [metagear](http://lajeunesse.myweb.usf.edu/metagear/metagear_basic_vignette.html#generating-different-prisma-plot-layouts)]
]
]
---
## Data collection
```{r,echo=FALSE,out.width="80%"}
# All defaults
knitr::include_graphics("graphics/formr.png")
```
.small[https://link.springer.com/content/pdf/10.3758/s13428-019-01236-y.pdf]
---
## formr
.flex[
.w-40.center[
```{r,echo=FALSE,out.width="88%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/google-sheets-logo.png")
```
]
.w-20.center[
<br><br><br>
.font300[`r fa("plus", fill = "black")`]
]
.w-40.center[
```{r,echo=FALSE,out.width="70%"}
# All defaults
knitr::include_graphics("graphics/opencpu.jpeg")
```
.font150[OpenCPU]
]
]
---
```{r,echo=FALSE,out.width="100%"}
# All defaults
knitr::include_graphics("graphics/formr1.png")
```
.small[https://www.youtube.com/watch?v=_dW7QIjH3tc]
---
```{r,echo=FALSE,out.width="90%"}
# All defaults
knitr::include_graphics("graphics/formr2.png")
```
.small[https://formr.org]
---
## Qualitative research
Automated Transcription: [googleLanguageR](https://github.com/ropensci/googleLanguageR)
Qualitative Data Analysis: [RQDA](https://rqda.r-forge.r-project.org/)
Text mining: [tm](https://cran.r-project.org/web/packages/tm/vignettes/tm.pdf), [tidytext](https://cran.r-project.org/web/packages/tidytext/vignettes/tidytext.html)
Semantics analysis: [Latent Semantic Analysis](https://cran.r-project.org/web/packages/lsa/lsa.pdf)
.small[[CRAN Task View: Natural Language Processing](https://cran.r-project.org/web/views/NaturalLanguageProcessing.html)]
---
## Data cleaning
.pull-left[
The game changing first package with the "Tidy" philosophy- dplyr
```{r,echo=FALSE,out.width="80%"}
# All defaults
knitr::include_graphics("graphics/dplyr.png")
```
]
.pull-right[
Non-Tidy data cleaning code
```{r,eval=FALSE}
cars<-cars[cars$speed>10,]
cars$speed_over20<-cars$speed>20
```
Non-Tidy data cleaning code
```{r,eval=FALSE}
cars<-cars %>%
filter(speed>10) %>%
mutate(speed_over20=speed>20)
```
]
---
class: center, middle
.flex[
.w-70.center[
## .green["Tidy" philosophy]
<br>
To facilitate a .green[conversation] between a .green[human] and a .green[computer] about data. Less abstractly, implement a high-level design philosophy and low-level grammar and data structures .green[across a range of packages], so that learning one package makes it easier to learn the next.
]
.w-20.center[
```{r,echo=FALSE,out.width="80%",,fig.align="center"}
# All defaults
knitr::include_graphics("graphics/HW.jpeg")
```
### .green[Hadley Wickham]
[`r fa("github")`](https://github.com/hadley) [`r fa("twitter")`](https://twitter.com/hadleywickham)
]
]
---
## Study monitoring
```{r,echo=FALSE,out.width="80%"}
# All defaults
knitr::include_graphics("graphics/COVID.png")
```
.small[[flexdashboard](https://pkgs.rstudio.com/flexdashboard/)]
---
.small[
```{r}
library(palmerpenguins)
library(reactable)
penguins %>%
reactable( filterable = TRUE,
compact = TRUE, # for minimum row height
striped = TRUE, # banded rows
resizable = TRUE,
defaultPageSize = 5)
```
]
---
## Visualisation
```{r,echo=FALSE,out.width="70%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/plot_packages.png")
```
---
## BBC style ggplot2
```{r,echo=FALSE,out.width="80%"}
# All defaults
knitr::include_graphics("graphics/ggplot2.png")
```
.small[ [Source](https://bbc.github.io/rcookbook/)]
---
<iframe src="https://exts.ggplot2.tidyverse.org/gallery/" width="100%" height="600px"></frame>
---
## Interactive plot
```{r,echo=FALSE,results="hide",message=FALSE,warning=FALSE}
splom <- penguins %>%
rename(bl = bill_length_mm,
bd = bill_depth_mm,
fl = flipper_length_mm,
bm = body_mass_g)
splom <- ggpairs(splom, #<<
columns = 3:6,
aes(color = species)) +
theme(axis.text = element_blank())
```
.font200[.pull-left[
```{r palmer-event2, warning=FALSE,message=FALSE, results='hide'}
library(plotly)
ggplotly(splom,
width=500, height=500) %>%
highlight(on = "plotly_selected")
```
]]
.pull-right[
```{r ref.label="palmer-event2", echo=FALSE, warning=FALSE,message=FALSE,}
```
.font_small[Brush to see how selected points are highlighted in all panels.]]
---
## Interactive framework
<iframe src="https://quinnasena.shinyapps.io/r_logistic/" width="100%" height="500px"></frame>
---
## Statistics, Machine Learning & Simulation
.flex[
.w-50.center[
```{r,echo=FALSE,out.width="90%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/top_packages.png")
```
]
.w-50[ .small[
** .font150[.pink[One-stop-shop ]]** for a vast majority of statistical, ML and simulation methods.
[CRAN Task Views](https://cran.r-project.org/web/views/)
[Machine Learning & Statistical Learning](https://cran.r-project.org/web/views/MachineLearning.html)
[Survival Analysis](https://cran.r-project.org/web/views/Survival.html)
[Time Series Analysis](https://cran.r-project.org/web/views/TimeSeries.html)
[Meta-Analysis](https://cran.r-project.org/web/views/MetaAnalysis.html)
[Psychometric Models and Methods](https://cran.r-project.org/web/views/Psychometrics.html)
[Multivariate Statistics](https://cran.r-project.org/web/views/Multivariate.html)
[Cluster Analysis & Finite Mixture Models](https://cran.r-project.org/web/views/Cluster.html)
]]]
---
.flex[
.w-50[
## Display results
Staged processes of data cleaning, analysis and gathering results are outdated
Reproducibility and transparency have brought in new regimes for integrated framework
New system - Rmarkdown workflow
]
.w-50.center[
{{content}}
]
]
--
```{r,echo=FALSE,out.width="80%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/rmarkdown_workflow.png")
```
---
class: inverse
## R markdown
Make your analysis easily reproducible
Results interactive
Easier with formatting
[Example](https://carolinexgao.github.io/MBS_COVID/Analysis_COVID.html)
---
## Interactive with word
<iframe src="https://ardata-fr.github.io/officeverse/index.html" width="100%" height="500px"></frame>
---
## Write a paper
.flex[
.w-50[
```{r,echo=FALSE,out.width="100%"}
# All defaults
knitr::include_graphics("graphics/rticles.png")
```
]
.w-50.center[
{{content}}
]
]
--
```{r,echo=FALSE,out.width="100%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/rticles_paper.png")
```
---
## Make a poster
```{r,echo=FALSE,out.width="70%",fig.align="center"}
# All defaults
knitr::include_graphics("https://github.com/brentthorne/posterdown/blob/master/images/example_poster1.png?raw=true")
```
---
## Write a book
<iframe src="https://bookdown.org/" width="100%" height="500px"></frame>
---
class: inverse
## Presentation slides
--
Hope you like this example generated using xaringan
<img src="https://user-images.githubusercontent.com/163582/45438104-ea200600-b67b-11e8-80fa-d9f2a99a03b0.png" alt="Sharingan" width="180" />
---
## Share and collaborate with the community
--
.flex[
.w-55.center[
<img src="https://vanchiv.com/wp-content/uploads/2020/12/git-vs-github.png" width="530"/>
]
.w-45.center[
<img src="https://cdn.dribbble.com/users/138252/screenshots/2389144/media/c1b396ccfcecf9a668469df8bd6770f4.png?compress=1&resize=800x600&vertical=top" width="500" />
]
]
---
## Design a logo
```{r,fig.height=4,fig.width=8}
library(hexSticker)
s<-sticker(here::here("graphics/Logo.jpg"), package="", p_size=0, s_x=1, s_y=1,
s_width=.65, h_fill="white",h_size=2,
filename="inst/figures/imgfile.png")
s
```
---
## Build a website
<iframe src="https://robjhyndman.com/" width="100%" height="500px"></frame>
---
Popular packages [glogdown]("https://shilaan.rbind.io/post/building-your-website-using-r-blogdown") and [distill]("https://www.andreashandel.com/posts/distill-github-website")
<iframe src="https://emitanaka.org/" width="100%" height="500px"></frame>
---
.flex[
.w-90[
## Working with social media data
```{r,eval=FALSE}
library(rtweet)
## search for 10000 tweets using the rstats hashtag
rt <- search_tweets(
"#rstats", n = 10000, include_rts = FALSE) %>%
ts_plot() +
theme_classic()
```
```{r,echo=FALSE,out.width="50%"}
# All defaults
knitr::include_graphics("graphics/twitter.png")
```
]
.w-10.center[
![](graphics/rtweet.png)
]
]
---
## Web scraping
<iframe src="https://en.wikipedia.org/w/index.php?title=The_Lego_Movie&oldid=998422565" width="100%" height="500px"></frame>
---
.flex[
.w-90[
.small[
```{r,warning=FALSE,message=FALSE}
library(rvest)
table<-read_html("https://en.wikipedia.org/w/index.php?title=The_Lego_Movie&oldid=998422565") %>%
html_element(".tracklist") %>%
html_table()
table%>%
reactable( filterable = TRUE,
compact = TRUE, # for minimum row height
striped = TRUE, # banded rows
resizable = TRUE,
defaultPageSize = 4)
```
]
]
.w-10.center[
![](graphics/rvest.png)
]]
---
## The process integration: Tidy-flow
```{r,echo=FALSE,out.width="70%",fig.align="center"}
# All defaults
knitr::include_graphics("graphics/tidyv-flow.png")
```
---
class: inverse
## Conclusion
--
R has become a research tool beyond it's statistical and computational ability
--
There is a step learning curvy, but a large supportive community
--
R encourages collaborative, reproducible, interactive and creative research
--
.purple[So Use R]