generated from inSilecoInc/workshop_R_template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_04_rmarkdown.Rmd
1046 lines (685 loc) · 21.8 KB
/
_04_rmarkdown.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
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "R Markdown"
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("_04_rmarkdown.Rmd") -->
```{r setup_04, 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()
```
# Accessing and modifying `r gh()` repositories
---
# Prerequisites: `r gt()` & `r gh()`
## `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 & <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="40px"></img>
## Pandoc
```{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]
--
## rmarkdown <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="40px"></img> installed
```{r eval=FALSE}
# Install from CRAN
install.packages('rmarkdown')
```
---
class: inverse, center, middle
# Accessing and modifying repositories
![:custom_hr]()
## `r gh()`
---
# How to access repositories on `r gh()`
.pull-left[
## `git fork`
Copy any public repository to your `r gh()` account or organization without making changes to the upstream repository
.font80[`r nf()` Issues, branches, pull requests and other `r gh()` features will not be copied]
]
.pull-right[
## `git clone`
]
---
# How to access repositories on `r gh()`
.pull-left[
## `git fork`
Copy any public repository to your `r gh()` account or organization without making changes to the upstream repository
.font80[`r nf()` Issues, branches, pull requests and other `r gh()` features will not be copied]
]
.pull-right[
## `git clone`
Create a local copy of a `r gh()` remote repo from:
- your account
- another user
- `r gh()` organizations
]
---
# Committing changes to a `r gh()` repository
.pull-left[
## `git fork`
- Fork repo
- Make changes
- Submit a *Pull request* .font80[(next session)]
]
.pull-right[
## `git clone`
]
---
# Committing changes to a `r gh()` repository
.pull-left[
## `git fork`
- Fork repo
- Make changes
- Submit a *Pull request* .font80[(next session)]
]
.pull-right[
## `git clone`
- Clone repo
- Make changes
- Push / merge changes
.font80[`r nf()` Consider using *Pull requests* when collaborating on a repo (next session)]
.font80[`r nf()` must be a collaborator or organization member to push commits to a repo you do not own]
]
---
# Should I clone or should I fork?
.pull-left[
## `git fork`
- Begin a project from an existing public `r gh()` repo
- Propose changes to someone else's project
- Continue a project without affecting the upstream repo
]
.pull-right[
## `git clone`
]
---
# Should I clone or should I fork?
.pull-left[
## `git fork`
- Begin a project from an existing public `r gh()` repo
- Propose changes to someone else's project
- Continue a project without affecting the upstream repo
]
.pull-right[
## `git clone`
- Get a local copy of your `r gh()` repo
- Actively collaborate on a projects
.font80[`r tr()` Cloning is still required if forking a `r gh()` repo]
]
--
.font80[`r nf()` See [here](https://www.geeksforgeeks.org/difference-between-fork-and-clone-in-github/) and [here](https://www.theserverside.com/answer/Git-fork-vs-clone-Whats-the-difference) for more on the difference between forking and cloning]
---
# Forking vs cloning: what's happening?
<center><img src="img/part4/fc1.png" style="vertical-align: middle;margin:10px" width="325px"></img></center>
---
# Forking vs cloning: what's happening?
<center><img src="img/part4/fc2.png" style="vertical-align: middle;margin:10px" width="325px"></img></center>
---
# Forking
- Go to the `r gh()` repo you wish to fork and click on `Fork` .font70[(top-right)]
<center><img src="img/part4/fork.png" style="vertical-align: middle;margin:10px" width="500px"></img></center>
--
- Navigate to your profile to get the newly forked repo's URL
<center><img src="img/part4/clone.png" style="vertical-align: middle;margin:10px" width="250"></img></center>
--
- Clone the forked `r gh()` repository using your preferred protocol .font70[(coming up!)]
---
# Cloning
```sh
$ git clone <repo>
```
---
# Adding collaborators
- Navigate to your `r gh()` settings
- Go to `Collaborators`
- Click on `Add people` to invite collaborators
<center><img src="img/part4/collaborator.png" style="vertical-align: middle;margin:10px" width="800px"></img></center>
---
# `r lc()` Let's do this
## Fork a repository
## Clone a repository
## Add a collaborator
---
class: inverse, center, middle
# Markdown
![:custom_hr]()
## .font200[`r rfa("markdown")`]
---
# `r rfa("markdown")` Markdown
## Reproducibility workshop [`r gh()`](https://github.com/inSilecoInc/workshop_reproducibility)
### March 2021
---
# `r rfa("markdown")` Markdown
## Dynamic documents
- Creating dynamic documents to automate workflows
- Code & text living together
--
## Markup language
- Rendering text using tags to format document
- LaTex, HTML `r rfa("html5")`, Markdown `r rfa("markdown")`
- Forget word! `r rfa("ban")` `r rfa("file-word")` .font60[as much as allowed by collaborators]
--
## Computing language
- Code for analyses and figures
- `r rfa("r-project")`, Python `r rfa("python")`, Julia, Matlab, C++, ...
- Forget excel! `r rfa("ban")` `r rfa("file-excel")` .font60[as much as humanly possible]
---
# `r rfa("markdown")` Markdown
## The genesis
HTML markup is complex:
```html
<!DOCTYPE html>
<html>
<body>
<h1>Section header</h1>
<p>Paragraph</p>
</body>
</html>
```
---
# `r rfa("markdown")` Markdown
## The genesis
In comes markdown, a lightweight markup language:
> Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
> The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. .font90[[John Gruber, 2004](https://daringfireball.net/projects/markdown/)]
---
# `r rfa("markdown")` Markdown
## The genesis
.pull-left[
From this:
```html
<!DOCTYPE html>
<html>
<body>
<h1>Section header</h1>
<p>Paragraphe</p>
</body>
</html>
```
]
.pull-right[
To this:
```md
# Section header
Paragraph
```
]
---
# `r rfa("markdown")` Markdown
## Variants
- Original developers (John Gruber and Aaron Swartz, a.k.a. [The Internet's Own Boy](https://www.imdb.com/title/tt3268458/)) did not continue developing Markdown after its release in 2004
--
- Avid enthusiasts took care of that. The results: many variants.
- [GitHub Flavored Markdown (GFM)](https://docs.github.com/en/github/writing-on-github)
- [Kramdown](https://kramdown.gettalong.org/)
- [Markdown Extra](https://michelf.ca/projects/php-markdown/extra/)
- [Multi Markdow](https://github.com/fletcher/MultiMarkdown/wiki/MultiMarkdown-Syntax-Guide#math-support)
- [Pandoc's Markdown](https://pandoc.org/MANUAL.html)
--
- [CommonMark](https://commonmark.org/) is addressing standardizing issues with Markdown.
---
# `r rfa("markdown")` Markdown
## Pandoc's Markdown
**Why?**
- `r rfa("r-project")` uses it through [R Markdown](https://rmarkdown.rstudio.com/lesson-8.html)
--
**What is Pandoc?**
> a universal document converter
> `r rfa("markdown")` `r rfa("arrow-right")` <i>LaTeX</i> `r rfa("arrow-right")` `r rfa("file-pdf")`
<br/>
> `r rfa("markdown")` `r rfa("arrow-right")` `r rfa("file-word")`
<br/>
> `r rfa("html5")` `r rfa("arrow-right")` `r rfa("markdown")`
<br/>
> **...**
.fon80[See [Pandoc's website](https://pandoc.org/index.html) for a list of all possible conversions]
---
class: inverse, center, middle
# .font200[`r rfa("r-project")`]
![:custom_hr]()
<img src="img/part4/knitr.png" style="vertical-align: middle;margin:10px" width="120px"></img>
<img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="120px"></img>
---
# <img src="img/part4/knitr.png" style="vertical-align: middle;margin:10px" width="50px"></img> knitr
[`knitr`](https://cran.r-project.org/package=knitr) .font90[01/2012 (0.1) // 01/2021 (1.3.1)]
> Elegant, flexible, and fast dynamic report generation with R .font80[([Yihui Xie, creator](https://yihui.org/knitr/))]
--
- `knitr` executes code embedded in a dynamic document and "knits" it back into the document.
---
# <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="50px"></img> R Markdown
[`rmarkdown`](https://cran.r-project.org/package=rmarkdown) .font90[09/2014 (0.3.3) // 02/2021 (2.7)]
> Convert R Markdown documents into a variety of formats.
<center><img src="img/part4/Rmdformat.png" style="vertical-align: middle"></img></center>
---
class: inverse, center, middle
# <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="50px"></img> Basic anatomy
![:custom_hr]()
## .font160[**YAML** + `r rfa("markdown")` + `r rfa("r-project")`]
---
# <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="50px"></img> Basic anatomy
## R Markdown file
.pull-left[
- A `r rfa("markdown")` file written with (`r rfa("r-project")`) has the extension `.Rmd` (capital optional)
- Structured in three parts:
- .font80[**YAML**]: Metadata / front matter
- `r rfa("markdown")`: Text / document content
- `r rfa("r-project")`: Code chunks .font70[(optional)]
]
.pull-right[
<img src="img/part4/rmd.png" style="vertical-align: middle" width="100%"></img>
]
---
# <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="50px"></img> Basic anatomy
## Exporting .font80[*a.k.a.* knitting 🧶]
.pull-left[
- `knitr` executes the code and converts `.Rmd` to `.md`
- Pandoc renders the `.md` file to the output format you want.
]
.pull-right[
<img src="img/part4/Rmdformat.png" style="vertical-align: middle"></img>
]
---
# <img src="https://github.com/rstudio/rmarkdown/raw/main/man/figures/logo.png" style="vertical-align: middle;margin:10px" width="50px"></img> Basic anatomy
## Exporting .font80[*a.k.a.* knitting 🧶]
### `rmarkdown::render()`
- Use [`render()`](https://www.rdocumentation.org/packages/rmarkdown/versions/2.6/topics/render) from the [`rmarkdown`](https://cran.r-project.org/package=rmarkdown) package
- Generates the desired output from the `.Rmd` file
--
Main arguments:
```md
input: name of file to render
output_format: one or more output formats, as specified in the YAML header.
"all" exports all the specified formats (optional).
output_file: name of output file (optional).
```
--
Minimal example:
```{r, eval = FALSE}
rmarkdown::render(input = "myrmd.Rmd")
```
---
class: inverse, center, middle
# Metadata
![:custom_hr]()
## .font160[**YAML**]
---
# .font60[**YAML**] Metadata
- Contains the metadata of the document
- Starts and ends with three hyphens (---)
- Comes first in the `.Rmd` file
- Sets *Pandoc* document options with `key: value` (.font60[**YAML**] syntax)
- Available options depend on the output format .font90[(see `?html_document `, `?pdf_document`, `?word_document`)]
--
<br/>
Minimal .font60[**YAML**] metadata for `r rfa("file-pdf")` PDF output:
```yaml
---
output: pdf_document
---
```
---
# .font60[**YAML**] Metadata
## Document information
Title, author and date options
```yaml
---
title: "My document title"
date: "01-03-2021"
author: Me, you, them
output: pdf_document
---
```
---
# .font60[**YAML**] Metadata
## Document options: additional options
- There is a wide variety of [.font60[**YAML**] options](https://rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf) available
.font90[
```yaml
---
title: "My document title"
date: "01-03-2021"
author: Me, you, them
abstract: "The objective of our work was to ..."
fontfamily: fourier
linestretch: 1
fontsize: 10pt
geometry: margin=1in
urlcolor: red
citecolor: blue
output:
pdf_document:
toc: true
html_document:
toc: true
word_document:
toc: true
---
```
]
---
class: inverse, center, middle
# Text
![:custom_hr]()
## .font160[`r rfa("markdown")`]
---
# `r rfa("markdown")` Text formatting
.pull-left[
.font80[
```md
Normal text
```
]
]
.pull-right[
.font80[Normal text]
]
--
.pull-left[
.font80[
```md
_Italic_ *text*
```
]
]
.pull-right[
.font80[_Italic_ *text*]
]
--
.pull-left[
.font80[
```md
__Bold__ **text**
```
]
]
.pull-right[
.font80[__Bold__ **text**]
]
--
.pull-left[
.font80[
```md
***Bold italic*** **_text_**
```
]
]
.pull-right[
.font80[***Bold italic*** **_text_**]
]
--
.pull-left[
.font80[
```md
~~Strikethrough text~~
```
]
]
.pull-right[
.font80[~~Strikethrough text~~]
]
---
# `r rfa("markdown")` Document formatting
## Titles
.pull-left[
.font80[
```md
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
```
]
]
.pull-right[
.font80[
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
]
]
---
class: inverse, center, middle
# `r rfa("code")` Code chunks
<html><div style='float:left'></div><hr color='#ffdd55'style="margin-top: -60px;" size=1px width=720px></html>
## The `r rfa("r-project")` part
---
# `r rfa("code")` Code chunks
````md
This text is written in markdown
```{r}`r ''`
library(tibble)
data(iris)
head(iris)
```
````
- `r rfa("exclamation-triangle")` `r` between brackets `{}`, why is that?
- Where is the `r rfa("r-project")` code and the `r rfa("markdown")` section?
---
# `r rfa("code")` Code chunks
### Code
```{r, eval = FALSE}
library(tibble)
data(iris)
head(iris)
```
### Print output
```{r echo = FALSE, eval = TRUE}
library(tibble)
data(iris)
head(iris)
```
---
# `r rfa("code")` Code chunks
.pull-left[
### Code
```{r, eval = FALSE}
library(ggplot2)
data(iris)
ggplot(
data=iris,
aes(x = Sepal.Length,
y = Sepal.Width)
) +
geom_point(
aes(color=Species, shape=Species)
) +
xlab("Sepal Length") +
ylab("Sepal Width") +
ggtitle("Sepal Length-Width")
```
]
.pull-right[
### Graphic output
```{r echo = FALSE, eval = TRUE, dpi=300, fig.height=5, fig.width=5}
library(ggplot2)
data(iris)
ggplot(
data=iris,
aes(x = Sepal.Length,
y = Sepal.Width)
) +
geom_point(aes(color=Species, shape=Species)) +
xlab("Sepal Length") + ylab("Sepal Width") +
ggtitle("Sepal Length-Width")
```
]
---
# `r rfa("code")` Inline code chunks
### `r rfa("code")` Syntax
We studied `` `r
length(levels(iris$Species))` `` iris species and took
measurements on `` `r
nrow(iris)` `` flowers.
We found that Iris virginica had the longest sepal with a mean of
`` `r
mean(subset(iris,Species=="virginica")$Sepal.Length)`
`` millimeters!
### `r rfa("file-alt")` Output
````md
This text is written in markdown.
We studied `r length(levels(iris$Species))` iris species and took measurements on `r nrow(iris)` flowers.
We found that Iris virginica had the longest sepal with a mean of `r mean(iris$Sepal.Length[iris$Species=="virginica"])` millimeters!
````
---
class: inverse, center, middle
# `r rfa("rocket")` Chunk options
<html><div style='float:left'></div><hr color='#ffdd55' style="margin-top: -60px;" size=1px width=720px></html>
---
# `r rfa("code")` Code chunk options
.pull-left[
- Place between curly braces
`{r option=value}`
- Multiple options separated by commas
`{r option1=value, option2=value}`
- Label your code chunk!
<img height="160px" width="160px" src="https://d33wubrfki0l68.cloudfront.net/6fcddff214345601f998805adce94ab0e21d8615/2a098/screenshots/rmarkdown-chunk-nav.png"></img>
]
.pull-right[
.font90[
````md
```{r dispIris, option1=value, option2=value}`r ''`
library(tibble)
data(iris)
head(iris)
```
````
]
]
---
# `r rfa("code")` Code chunk options
## What output each option suppresses?
Option | Run code | Show code | Output | Plots | Messages | Warnings
-------------------|:--------:|:---------:|:------:|:-----:|:--------:|:-------:
`eval = FALSE` |`r rfa("times")`| |`r rfa("times")`|`r rfa("times")`|`r rfa("times")`|`r rfa("times")`
`include = FALSE` | |`r rfa("times")`|`r rfa("times")`|`r rfa("times")`|`r rfa("times")`|`r rfa("times")`
`echo = FALSE` | |`r rfa("times")`| | | |
`results = "hide"` | | |`r rfa("times")`| | |
`fig.show = "hide"`| | | | `r rfa("times")`| |
`message = FALSE` | | | | |`r rfa("times")`|
`warning = FALSE` | | | | | |`r rfa("times")`
Table from [R for Data Science](https://r4ds.had.co.nz/r-markdown.html#chunk-options)
---
# `r rfa("book")` The `down` universe
- [`bookdown`](https://bookdown.org/): Write a notebook
- [`csasdown`](https://github.com/pbs-assess/csasdown): Write a CSAS document .font60[(next session)]
- [`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 .font60[(like this one)]
- [`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
--
***Other resources:***
- [R Markdown book](https://bookdown.org/yihui/rmarkdown/)
- [knitr documentation](https://yihui.org/knitr/)
- [inSileco web book (fr)](https://kevcaz.insileco.io/Rmarkdowndocfr/)
- [inSileco reproducibility workshop](https://www.insileco.io/workshop_reproducibility/#89)
---
# `r lc()` Let's do this
## Create a simple `rmd` document in our repo
## Create html document
```{r echo=FALSE, out.width="100%"}
knitr::include_graphics("img/part4/rmarkdownflow_html.png")
```
---
class: inverse, center, middle
# GitHub Pages
<html><div style='float:left'></div><hr color='#ffdd55' style="margin-top: -60px;" size=1px width=720px></html>
## Transform your `r gh()` repo into a website
---
# GitHub Pages
GitHub provides a free web hosting services called [GitHub Pages](https://docs.github.com/en/pages) that allows you to turn your `r gh()` repo into websites
> GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.
---
# GitHub Pages
There are [multiple advantages](https://medium.com/@cheukting.ho/newbie-tips-5-advantage-of-using-github-pages-for-hosting-35bee4c1ce14) to use GitHub Pages for developpers
- Free
- Version control
- Custom domain
- Supports HTTPS
--
In our case, it also makes it easy to share and disseminate our research and our work through:
- [Blogs](https://blog.insileco.io/)
- [Websites](https://www.insileco.io/)
- [Books & reports](https://kevcaz.insileco.io/Rmarkdowndocfr/)
- [Presentations](https://www.insileco.io/learning_git/)
---
# GitHub Pages
## How to create github page from repository
1. Open a new GitHub repository and activate GitHub pages
2. Link this new repo to a RStudio project
3. Add a `.Rmd` document and generate the HTML document (we know that part!)
4. Declare (`add`) and document (`commit`) the modifications on the repository
5. Send these modifications with the HTML output on GitHub via RStudio
---
# GitHub Pages
## How to create github page from repository
1. Open a new GitHub repository and ***activate GitHub pages***
2. Link this new repo to a RStudio project
3. Add a `.Rmd` document and generate the HTML document (we know that part!)
4. Declare (`add`) and document (`commit`) the modifications on the repository
5. Send these modifications with the HTML output on GitHub via RStudio
--
`r tr()` exported html must be named `index.html`
---
# GitHub Pages
## Activating GitHub Pages
- Navigate to your `r gh()` settings
- Go to `Pages`
- Select `main` branch as source
<center><img src="img/part4/ghp1.png" style="vertical-align: middle;margin:10px" width="650px"></img></center>