-
Notifications
You must be signed in to change notification settings - Fork 0
/
presentation.Rmd
407 lines (284 loc) · 10.1 KB
/
presentation.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
---
title: "R, Reproducibility and Communication"
subtitle: "Best pratices and tips!"
author: "Andre Fonseca"
date: "`r Sys.Date()`"
output:
xaringan::moon_reader:
css: [default, hygge, robot-fonts]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
beforeInit: "macro.js"
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = FALSE, fig.path = "figures/")
options(htmltools.dir.version = FALSE)
library(knitr)
```
# Presentation outline
- Can we talk about reproducibility?
- A gentle introduction to Rstudio
+ Panes, Shortcuts and Addins
- Organizing myself with Rprojects!
+ What you shouldn't do...
--
- Day-to-day workflow
- Communicate your results like a boss!
- Welcome to RMarkdown
- Hands-on moment...
- Coding version: last but not less important
- Finally! To sum up!
---
background-image: url(figures/reproducibility.jpg)
background-size: cover
class: center
# Can we talk about reproducibility?
--
</br>
.content-box-grey[.Large[Reproducibility or Repeatability]]
--
</br>
.full-width[
.content-box-grey[
"The reproducibility of data is a measure of whether results in a paper can be attained by a different research team, using the same methods. This shows that the results obtained are not artifacts of the unique setup in one research lab. [1]"
]
]
---
class: center, middle, inverse
<iframe width="1300" height="600" src="https://www.youtube.com/embed/s3JldKoA0zw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>
---
class: center, middle, inverse
# Did you like it?
### We gonna have a small slice of these **good practices** today
---
# A gentle introduction to Rstudio
RStudio is an integrated development environment for R, a programming language for statistical computing and graphics. The RStudio IDE is developed by RStudio, Inc., a commercial enterprise founded by JJ Allaire, creator of the programming language ColdFusion.
How to install? Check it [out](www.google.com.br)!
---
class: center
# Panes, Addins and Shortcuts
![:scale 50%](figures/rstudio_ide.png)
**Figure 1. Rstudio panels.** *Source*, coding area similar text editor. *Console*, all code typed into "Source" area will be evaluated into R Console. *Environment/History*, in this panel we can inspect what objects were loaded into your workspace. *Files/Plots/Packages/Help*, another useful panel, allowing directory browsing, plot visualization, package installation or selection.
---
class: center
![](figures/rstudio_addin.png)
### There's plenty of different *addins*. For instance, [remedy](https://github.com/ThinkR-open/remedy) it is a nice one to edit markdown syntax.
---
class: center
![](figures/rstudio_shortcuts.png)
## For now keep in my **Ctrl+Alt+I** to insert a new code chunk
---
# Organizing myself with Rprojects!
**RStudio** projects make it straightforward to divide your work into multiple contexts, each with their own working directory, workspace, history, and source documents.
But what it means? In short, productivity and .Large[**less headache**]
---
## The .RProj in a nutshell!
1. Creates a project file (with an .Rproj extension) within the project directory. This file contains various project options (discussed below) and can also be used as a shortcut for opening the project directly from the filesystem.
2. Creates a hidden directory (named .Rproj.user) where project-specific temporary files (e.g. auto-saved source documents, window-state, etc.) are stored. This directory is also automatically added to .Rbuildignore, .gitignore, etc. if required.
3. Loads the project into RStudio and display its name in the Projects toolbar (which is located on the far right side of the main toolbar)
[Oficial Documentation](https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects)
![](figures/rstudio_project_bar.png)
---
## For your convenience
1. Click the **File** menu button, then **New Project**.
2. Click **New Directory**.
3. Click **New Project**.
4. Type in the name of the directory to store your project, e.g. **my_project**.
5. If available, select the checkbox for **Create a git repository.**
6. Click the **Create Project** button.
(WAIT! We gonna have a hands-on moment)
---
class: center
### What you shouldn't do...
##### setwd() and rm(list = ls())
![:scale 60%](figures/r_newbie_style.png)
*Yeah... I know... You are still doing this, right?*
---
# Presentation outline
- Can we talk about reproducibility?
- A gentle introduction to Rstudio
- Organizing myself with Rprojects!
- **Day-to-day workflow**
- Communicate your results like a boss!
- Welcome to RMarkdown
--
+ Markdown syntax to document style
--
+ Saving as HTML, pdf or doc
--
- Hands-on moment o/
- Coding version: last but not less important
- Finally! To sum up!
---
class: center
# Day-to-day workflow
![](figures/datascience_workflow.png)
#### Import > Clean and manipulate > Modeling > Visualize > Communicate!
---
# Communicate your results like a boss!
--
.pull-left[
#### Option 1 -Traditional way
- Excel Sheet (.xls)
- Presentations (.pptx)
- LaTex (.pdf)
- Documents (.doc)
**A lot of copy-and-paste and confusion** <br/>
:(
]
--
.pull-right[
#### Option 2 - The boss way
- RMarkdown (.doc, .pdf, .html, .pptx)
<br/><br/><br/>
.Large[**Extremely faster and easier!**]
]
---
# Welcome to RMarkdown
Basically, it is an authoring framework for data science developed by RStudio Team. RMarkdown is an R package build upon **Markdown** is a text-to-HTML conversion tool for web writers. Originally Markdown was written in **Perl**, allowing you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
--
.center[
### Analyze > Comment > Document > Share
]
.center[
![not_bad](https://media.giphy.com/media/jVTrhpvPbkgYVJ5eZh/giphy.gif)
]
---
class: inverse
### Markdown syntax to document style
<iframe src="documents/rmarkdown-2.0.pdf" width="95%" height="80%">
This browser does not support PDFs. Please download the PDF to view it: Download PDF
</iframe>
---
class: center
# Saving as HTML, pdf or doc
![:scale 60%](figures/rmarkdown_and_knitr.png)
---
### Almost in the hands-on moment! But first, a few concepts in RMarkdown!
.pull-left[
````markdown
---
title: "Document Name"
author: "Author"
date: "Month DD, YYYY"
output: html_document
---
## R Markdown
Add description here.
`r ''````{r cars}
summary(cars)
```
````
]
.pull-right[
## - YAML
## - Markdown
## - R Code
]
---
# Hands-on moment...
1. Click the *File* menu button, then *New File*.
2. Click *R Markdown*.
3. Type the title *My R Mardown*.
4. Type the author name *It is me, Mario*.
5. Click *HTML* as default output format.
6. Finally, click the *OK* button.
<br/>
.center[
![coding_monkey](https://media.giphy.com/media/zOvBKUUEERdNm/giphy.gif)
### Let's code a little bit!
]
---
# Presentation outline
- Can we talk about reproducibility?
- A gentle introduction to Rstudio
- Organizing myself with Rprojects!
- Day-to-day workflow
- Communicate your results like a boss!
- Welcome to RMarkdown
- Hands-on moment o/
- **Coding version: last but not less important**
--
+ Git and Git hosting services
--
+ Using Git through RStudio
--
- Finally! To sum up!
---
# Coding version: last but not less important
Briefly, **version control (VCS)** is a system that records changes to a file or set of files over time so that you can recall specific versions later. Nowadays, there two main VCS, Apache subversion (SVN) and git.
**Git** is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
---
class: center, middle
![:scale 90%](figures/git_flowchart.png)
#### Coding > Adding (Stage Area) > Commiting > Push
---
background-image: url(figures/git_flavors.jpg)
background-size: cover
class: center, bottom
# Git and Git hosting services
### Wait! Let's create a GitHub [account](https://http://github.com) !
#### Need help? Click [here](https://www.youtube.com/watch?v=ezxRcdJ8glM)
---
## A few basic command in Git that you should know...
- init
- clone
- remote
--
- status
- add
- commit
- push
--
- pull
- merge
--
#### We are not covering git commands in this class, but I strongly suggest you guys understand more about the program. Please check out this outstanding [tutorial](https://rogerdudler.github.io/git-guide/)
---
class: center
# Using Git through RStudio
<video width="80%" height="40%" controls>
<source src="figures/git_rstudio_integration.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
---
# Finally! To sum up!
1. We saw how powerful are R projects and how it can avoid headaches!
2. We learn how **RMarkdown** can make our research faster and reproducible.
3. We got a few tips on how to properly communicate and share our scientific results.
4. We were introduced to **Git** and **GitHub** repository.
5. We mixed all the previous knowledge to make our life easier :)
6. Finally, we had fun!
---
# Is this all? Of course...
#### *But no*
### More about good pratices
- You may should take a look in **Lintr**
- Or **Tidyverse** coding style
- Project organization **workflowr**
---
# A few extras :)
### To study
- Bookdown and Blogdown
- Shiny Apps
- Rticles package
- **R presentations**
---
class: center, middle, inverse
![mind_blown](https://media.giphy.com/media/3kD2Eciolhy4VOzjRV/giphy.gif)
# Thank you!
---
# References
1. Repeatability vs. Reproducibility [1]
2. Is there a reproducibility crisis in science? [2]
3. RMarkdown CheatSheet by RStudio [3]
4. Rstudio CheatSheet [4]
[1]: https://www.technologynetworks.com/informatics/articles/repeatability-vs-reproducibility-317157 "Repeatability vs. Reproducibility"
[2]: https://www.youtube.com/watch?v=FpCrY7x5nEE "Is there a reproducibility crisis in science?"
[3]: https://rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf "RMarkdown CheatSheet by RStudio"
[4]: https://rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf "Rstudio CheatSheet"