generated from inSilecoInc/workshop_R_template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_05_csas.Rmd
603 lines (409 loc) · 14.2 KB
/
_05_csas.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
---
title: "Pull Requests & csasdown"
output:
xaringan::moon_reader:
css: [default, rd.css, rd-font.css, "hygge"]
lib_dir: assets
seal: false
nature:
highlightStyle: dracula
countIncrementalSlides: false
beforeInit: "macros.js"
---
<!-- rmarkdown::render("_05_csas.Rmd") -->
```{r setup_05, include = FALSE}
source("_setup.R")
# knitr::clean_cache(TRUE)
htmltools::tagList(
xaringanExtra::use_clipboard(
button_text = "<i class=\"fa fa-clipboard\"></i>",
success_text = "<i class=\"fa fa-check\" style=\"color: #37abc8\"></i>",
),
rmarkdown::html_dependency_font_awesome()
)
xaringanExtra::use_scribble()
```
# Working collaboratively with GitHub `r gh()`
---
# Prerequisites
## `r gt()` installed
```{bash}
git --version
```
--
## Access to a GitHub `r gh()` account
- Sign up on https://github.com, then go to https://docs.github.com/en/get-started
---
# Prerequisites
## Pandoc
.font90[
```{bash, eval=FALSE}
pandoc --version
#> pandoc 2.11.4
```
]
.font80[`r nf()` Installed with `r rp()` Studio, otherwise go [here](https://pandoc.org/installing.html) for installation info]
--
## <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="40px"></img> rmarkdown installed
.font90[
```{r eval=FALSE}
# Install from CRAN
install.packages('rmarkdown')
```
]
--
## <img src="https://yihui.org/images/logo-tinytex.png" style="vertical-align: middle;margin:10px" width="40px"></img> TinyTex
.font90[
```{r eval = FALSE}
install.packages("tinytex")
tinytex::install_tinytex()
```
]
# Working collaboratively with GitHub `r gh()`
---
class: inverse, center, middle
# Creating CSAS reports: csasdown
![:custom_hr]()
[<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="150px"></img>](https://github.com/pbs-assess/csasdown)
---
# `r bk()` The `down` universe
- [`bookdown`](https://bookdown.org/): Write a notebook
- ***[`csasdown`](https://github.com/pbs-assess/csasdown): Write a CSAS document***
- [`thesisdown`](https://github.com/ismayc/thesisdown): Write a thesis
- [`rticles`](https://github.com/rstudio/rticles): Write a scientific article
- [`posterdown`](https://github.com/brentthorne/posterdown): Create a poster
- [`xaringan`](https://github.com/yihui/xaringan): Create nice presentation (e.g. this presentation)
- [`vitae`](https://github.com/mitchelloharawild/vitae): Build a CV
- [`blogdown`](https://bookdown.org/yihui/blogdown/): Generate a blog
- [`pkgdown`](https://pkgdown.r-lib.org/): Generate R package documentation
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
`csasdown` .font90[v.0.0.10.9000]
[`r gh()`](https://github.com/pbs-assess/csasdown)
[`r rfa("desktop")`](https://www.dropbox.com/s/7m23mh3yfhk5ah8/csasdown-slides.pdf?dl=1)
```{r echo=FALSE, out.width="100%"}
knitr::include_graphics("img/part5/csasdown_begins.png")
```
Developed by Sean Anderson
[`r rfa("envelope")`](mailto:[email protected])
[`r rfa("globe-americas")`](https://seananderson.ca/)
> Reproducible CSAS Reports with R Markdown
--
> csasdown is an R package that facilitates generating Canadian Science Advisory Secretariat (CSAS) documents in PDF or Word format using R Markdown and bookdown.
--
> csasdown gratefully builds on the work of many others including bookdown, thesisdown, and csas-style by Yihui Xie, Chester Ismay, Nick Solomon, Ben Marwick, Chris Grandin, Andrew Edwards, Matthew Grinnel
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## Install the package
```{r eval = FALSE}
install.packages("remotes")
remotes::install_github("pbs-assess/csasdown")
```
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## Create a draft
There are 3 types of documents available
- Research Document: `csasdown::draft("resdoc")`
- Technical Report: `csasdown::draft("techreport")`
- Science Response: `csasdown::draft("sr")`
--
.font90[`r nf()` By default, the draft files are added in the current root folder. You can use the argument `create_dir = TRUE` for the draft to be created in a folder entitled `index/`]
--
.font90[`r nf()` Each draft contains valuable information included by the authors. Create the drafts and consult the documents!]
--
```{r eval = FALSE}
csasdown::draft("techreport")
```
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## Create a draft
.pull-left[
```{r echo=FALSE, out.width="50%"}
knitr::include_graphics("img/part5/resdoc_draft1.png")
```
]
.pull-right[
- Structure of the resulting document
]
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## `index.Rmd`
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/resdoc_draft2.png")
```
- Main document for the report
- Edit authors, title, abstract, affiliations, etc
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## Chapters
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/resdoc_draft3.png")
```
- One document, or partial document, per chapter
- Begin chapter with main title formatting `# Title`
- Add text, figures, tables, etc
.font80[`r tr()` You do not have to follow this logic, as long as the documents are well referenced in `_bookdown.yml` (next slide)]
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## `bookdown.yml`
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/resdoc_draft4.png")
```
- Specifies which partial documents and the order in which the documents are included in the final report
---
# [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: middle;margin:10px" width="50px"></img>](https://github.com/pbs-assess/csasdown) csasdown
## Render the CSAS document
```{r eval = FALSE}
bookdown::render_book("index.Rmd")
```
---
class: inverse, center, middle
# Collaborating on CSAS reports
![:custom_hr]()
## .font400[`r gh()`] [<img src="https://github.com/pbs-assess/csasdown/raw/master/man/figures/csasdown-logo.png" style="vertical-align: top;margin:10px" width="110px"></img>](https://github.com/pbs-assess/csasdown)
---
# Working collaboratively with GitHub
## Collaborative development models
.pull-left[
***Shared repository model***
- Collaborators are granted direct access to a single shared repo
- Create branches for development
- Merge changes to main branch
- Small teams and organizations collaborating on private projects
]
---
# Working collaboratively with GitHub
## Collaborative development models
.pull-left[
***Shared repository model***
- Collaborators are granted direct access to a single shared repo
- Create branches for development
- Merge changes to main branch
- Small teams and organizations collaborating on private projects
]
.pull-right[
***Fork and pull model***
- Fork repo and push changes to your own repo
- No permission required
- Changes pulled to upstream repo through pull requests
- Favoured by open source projects for independent development
]
---
# Working collaboratively with GitHub
## Collaborative development models
.pull-left[
***Shared repository model***
- Collaborators are granted direct access to a single shared repo
- Create branches for development
- Merge changes to main branch
- Small teams and organizations collaborating on private projects
]
.pull-right[
***Fork and pull model***
- Fork repo and push changes to your own repo
- No permission required
- Changes pulled to upstream repo through pull requests
- Favoured by open source projects for independent development
]
.pull-left[
`r nf()` ***pull requests*** are recommended
]
.pull-right[
`r nf()` ***pull requests*** are mandatory
]
---
# Pull requests
## What are they?
> Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
.font80[`r nf()` Go [Here](https://co-learning.eu/2017/10/04/why-and-how-do-we-use-pull-request/) for all you need to know on pull requests on `r gh()`]
---
# Pull requests
## Why use them?
- Code review
- Test and validate code
- Find errors or improvement opportunities
- Education / training of other developers
- Allow less experienced coder to contribute without worrying they will mess up the main project
.font80[`r nf()` [Here](https://co-learning.eu/2017/10/04/why-and-how-do-we-use-pull-request/) is a nice blog post on the benefits of using pull requests for co-development]
---
# Pull requests
## What is the process of creating one?
.pull-left[
***Shared repository model***
- Create a branch
- Make, commit and push changes to branch
- Create pull request
- Assign pull request
- Review process
- Merge branch to base branch
]
---
# Pull requests
## What is the process of creating one?
.pull-left[
***Shared repository model***
- Create a branch
- Make, commit and push changes to branch
- Create pull request
- Assign pull request
- Review process
- Merge branch to base branch
]
.pull-right[
***Fork and pull model***
- Fork a repository
- Make, commit and push changes to fork
- Create pull request
- Assign pull request
- Review process
- Merge fork to upstream repo
]
---
# Pull requests
## What is the process of creating one?
.pull-left[
***Shared repository model***
- Create a branch
- Make, commit and push changes to branch
- **Create pull request**
- **Assign pull request**
- **Review process**
- Merge branch to base branch
]
.pull-right[
***Fork and pull model***
- Fork a repository
- Make, commit and push changes to fork
- **Create pull request**
- **Assign pull request**
- **Review process**
- Merge fork to upstream repo
]
---
# Creating pull requests
- Navigate to repo on `r gh()`
- Click on *Pull request*
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/pr1.png")
```
---
# Creating pull requests
- Click on *New pull request*
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/pr2.png")
```
---
# Creating pull requests
***From a branch:***
.pull-left[
- Select branches to merge
- `base`: merge into
- `compare`: merge from
]
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/pr3.png")
```
---
# Creating pull requests
***From a Fork:***
.pull-left[
- Select repos to merge
- `base repository`: upstream repo
- `head repository`: forked repo
]
.pull-right[
- Select branches to merge
- `base`: merge into
- `compare`: merge from
]
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/pr4.png")
```
---
# Creating pull requests
- Click on *Create pull request*
```{r echo=FALSE, out.width="90%"}
knitr::include_graphics("img/part5/pr5.png")
```
---
# Creating pull requests
- Write your pull request description
```{r echo=FALSE, out.width="67%"}
knitr::include_graphics("img/part5/pr6.png")
```
- .font80[`r nf()` [Writing A Great Pull Request Description](https://www.pullrequest.com/blog/writing-a-great-pull-request-description/)]
- .font80[`r nf()` [How to write the perfect pull request](https://github.blog/2015-01-21-how-to-write-the-perfect-pull-request/)]
---
# Creating pull requests
- Click on *Create pull request*
```{r echo=FALSE, out.width="67%"}
knitr::include_graphics("img/part5/pr7.png")
```
---
# Creating pull requests
And you're done!
```{r echo=FALSE, out.width="100%"}
knitr::include_graphics("img/part5/pr8.png")
```
---
# Assigning pull requests
.pull-left[
`r nf()` You can assign reviewer(s) to your pull request while you are creating the pull request, or after it's been created
]
.pull-right[
```{r echo=FALSE, out.width="60%"}
knitr::include_graphics("img/part5/pr9.png")
```
]
---
# `r lc()` Let's do this
## Create a branch
## Make a change
## Create a pull request
## Assign pull request
---
# Reviewing pull requests
- Go to the new pull request in the *Pull request* tab
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev1.png")
```
---
# Reviewing pull requests
- Go to *Files changed* to visualize proposed changes in the pull request
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev2.png")
```
---
# Reviewing pull requests
- Review changes, add comments, commit changes of your own
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev2.png")
```
---
# Reviewing pull requests
- Click *Review changes* and add a general comment describing your feedback
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev3.png")
```
---
# Reviewing pull requests
- You can comment, approve or request improvements
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev4.png")
```
---
# Reviewing pull requests
- When done, click *submit review*
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev5.png")
```
---
# Reviewing pull requests
- Once completed, merge and close pull request
```{r echo=FALSE, out.width="80%"}
knitr::include_graphics("img/part5/pr-rev6.png")
```
.font80[`r nf()` Can be an interative process, think peer-review!]
---
# `r lc()` Let's do this
## Review & merge pull request