80’s idea from D. Knuth:
write code for humans, not for computer
June 17th, 2019
80’s idea from D. Knuth:
write code for humans, not for computer
One document to rule them all with both text & code
=> export to different formats
Science reproducibility crisis
Is most scientific research false ? Ioanidis et al.
have you had to redo a whole analysis with just slightly different data
(e.g. 1 patient added or removed ?)
Fench book on reproducible research:
Vers une recherche reproductible : faire évoluer ses pratique
R
: .rmd
(“Rmarkdown”)markdown
: lightweight structured text
Rmarkdown = R
+ markdown
Rmarkdown + pandoc
=> output in many formats (.docx
, .pdf
, .html
, etc…)
These materials have been prepared in Rmarkdown
.Rmd
structure--- title: 'BADAS: Part II' subtitle: "Dynamic & Reproducible reporting with `Rmarkdown`" author: "Boris Hejblum & Loïc Ferrer" date: "June 17, 2019" output: ioslides_presentation: number_sections: no ---
Text
Narration
Code Chunks
```{r}
```
results
(default is 'markup'
)
'asis'
- passthrough results'hide'
- do not display results'hold'
- put all results below all codeeval
- Run code in chunk (default is TRUE
)
echo
- Display code in output document (default is TRUE
)
message
- display code messages in document (default is TRUE
)
error
- Display error messages in output document (TRUE
) or stop render when errors occur (FALSE
)
(default is FALSE
)
tidy
- tidy code for display (default is FALSE)warning
- display code warnings in document (default = TRUE)collapse
- collapse all output into single block (default = FALSE)highlight
- highlight source code (default = TRUE)include
- include chunk in doc after running (default = TRUE)comment
- prefix for each line of results (default = ‘##’)fig.align
- figure postion: 'left'
, 'right'
, or 'center'
fig.cap
- figure caption as character string (default is NULL
)fig.height
, fig.width
- Dimensions of plots in inchesout.width
- only in pdf: size of the figureLong running code chunks
cache
- cache results for future knits (default is FALSE
)cache.path
- directory to save cached results in (default is "cache/"
)dependson
- chunk dependencies for caching (default is NULL
)child
- file(s) to knit and then include (default is NULL
)engine
- code language used in chunk (default = ‘R’)*italic*
— italic**bold**
— bold~~no~~
— verbatim code
^2^
— superscript2~2~
— subscript2$\alpha = \beta^2$
— LaTeX equations: \(\alpha = \beta^2\)# Header1 {#anchor}
## Header 2
Jump to [Header 1](#anchor)
A footnote [^1]
[^1]
: Here is the footnote.
![Caption](pathtoimage.png)
- Bullet 1 - Bullet 2
1. item 1 2. item 2
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12|
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
Right | Left | Default | Center |
---|---|---|---|
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
--- bibliography: refs.bib csl: style.csl ---
Smith cited [@smith04]
.
Smith cited without author [-@smith04]
.@smith04
cited in line.
Rmarkdown book by Yihui Xie, JJ Allaire & G Grolemund
(very) comprehensive…
.Rmd