- lack of time: ultimately, reproducibility is faster
- fear of plagiarism: low risks in practice
- internal work, no need to share: almost never true
- one good reason: lack of tools to facilitate reproducibility
2019-11-19
Some opinions on whether reproducibility is needed:
Be nice to your future selves!
Let us change our traditional attitude to the construction of programs: instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to humans what we want the computer to do.(Donald E. Knuth, Literate Programming, 1984)
Current workflows use the following equation:
markdown (.md
) + = Rmarkdown (.Rmd
)
Example:
knitr::knit2html("foo.Rmd")
\(\rightarrow\) foo.html
rmarkdown::render("foo.Rmd")
\(\rightarrow\) foo.pdf
rmarkdown::render("foo.Rmd")
\(\rightarrow\) foo.doc
...
```{r chunk-title, ...} a <- rnorm(1000) hist(a, col = terrain.colors(15), border = "white", main = "Normal distribution") ```
results in:
a <- rnorm(1000) hist(a, col = terrain.colors(15), border = "white", main = "Normal distribution")
```{r another-chunk-title, ...} [some R code here] ```
where ...
are options for processing and formatting, e.g:
eval
(TRUE
/FALSE
): evaluate code?echo
(TRUE
/FALSE
): show code input?results
("markup"/"hide"/"asis"
): show/format code outputmessage/warning/error
: show messages, warnings, errors?cache
(TRUE
/FALSE
): cache analyses? See http://yihui.name/knitr/options for details on all options.
rmarkdown
can generate different types of documents:
html
, pdf
)rticles
package (.pdf
).pdf
).doc
)html
, pdf
)rmarkdown
: toy example 1/2
---
title: "A toy example of rmarkdown"
author: "John Snow"
date: "2019-11-19"
output: html_document
---
This is some nice R code:
```{r rnorm-example} x <- rnorm(100) x[1:6] hist(x, col = "grey", border = "white") ```
rmarkdown
: toy example 1/2rmarkdown::render("foo.Rmd")
rmarkdown
is just the beginningREADME
filemy_file <- "C:\project1\data\data.csv"
here
for portable paths e.g.:my_file <- here("data/data.csv")
éèçêäÏ*%~!?&
FooBar
\(\neq\) foobar
\(\neq\) FOOBAR
snake_case
is currently recommended for packages##
)lintr
packagelintr
Because you never know what can happen..