-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reuse.Rmd
41 lines (30 loc) · 1.66 KB
/
Reuse.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
---
title: "Reuse with R, R Markdown & git)"
author: "Paul Sharpe"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
beamer_presentation:
fig_caption: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::read_chunk('external.R')
```
## R Markdown
* Quick (like a wiki) communication tool PDF, Word, HTML ...
* ... [Source that generated this presentation](https://github.com/earcanal/documents/blob/master/Reuse.Rmd)
## Git(hub)
* De facto open collaborative development tool
* Feature rich, but you can get by with limited vocabulary: `clone`, `add`, `commit`, `push`, `diff`. R Studio can interact with git, and there's GUI for your operating system if you don't like the command line.
* Well written git commit messages are your [project history metadata](https://github.com/earcanal/rsvp-task/commits/master)
## Don't Repeat Yourself (DRY)
* Minimise viral code!
* Instead, reuse code using functions, R packages, and ...
## ... knitr
The following number came from the chunk defined as `# ---- external-chunk ----` in [external.R](https://github.com/earcanal/documents/blob/master/external.R):
```{r external-chunk}
```
* Can't reuse files using symlinks due to [an issue in knitr](https://github.com/rstudio/rmarkdown/issues/1508) ...
* ... so [include chunks with `knitr::read_chunk()`](https://yihui.name/knitr/demo/externalization/)
* knitting your markdown won't populate your Global Environment because chunks are processed in temporary R sessions
* This is probably a *feature*, because R scripts allow you to use R Studio debugging tools. Debugging tools are crippled in R Markdown files (becuase chunks are processed in temporary R sessions)