Associated Material
Module: Module 06 - Communicate
Readings:
What is RMarkdown
There are three main components to an RMarkdown document
- The YAML header which is surrounded by
---
s and provides information for the compiling
process
- R code chunks which are surrounded by
```
s
- Text which can be formatted using the Markdown language.
A reference guide of RMarkdown syntax can be found through
Help
-> Cheat Sheets
->
R Markdown Reference Guide
in the RStudio menu.
Example Rmd
Create your own RMarkdown document now from the template. To do this
go File
-> New File
->
R Markdown
.
Knitting
“Knit” or compile the document using the knit
button or
Ctrl + Shift + K.
Code Chunks
Code chunks look like:
```{r}
1 + 2
```
Code chunks are executed as part of the document “knitting” and
the code and output embedded in the document
Be aware of the working directory (don’t use
setwd()
). Ideally use the here
package to
manage paths.
LS0tCnRpdGxlOiAiWm9vbSBOb3RlcyAwNjogQ29tbXVuaWNhdGluZyBEYXRhIgpkYXRlOiAiU2VtZXN0ZXIgMiwgMjAyMiIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICB0b2M6IHRydWUKICAgIHRvY19mbG9hdDogdHJ1ZQogICAgdG9jX2RlcHRoOiAzCiAgICBjb2RlX2Rvd25sb2FkOiB0cnVlCiAgICBjb2RlX2ZvbGRpbmc6IHNob3cKLS0tCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0KbGlicmFyeShrbml0cikKCmtuaXRyOjpvcHRzX2NodW5rJHNldCgKICBjb21tZW50ID0gIiM+IiwKICBmaWcucGF0aCA9ICJmaWd1cmVzLzA2LyIsICMgdXNlIG9ubHkgZm9yIHNpbmdsZSBSbWQgZmlsZXMKICBjb2xsYXBzZSA9IFRSVUUsCiAgZWNobyA9IFRSVUUKKQoKCmBgYAoKPiAjIyMjIEFzc29jaWF0ZWQgTWF0ZXJpYWwKPgo+IE1vZHVsZTogW01vZHVsZSAwNiAtIENvbW11bmljYXRlXSgwNi1jb21tdW5pY2F0ZS5odG1sKQo+Cj4gUmVhZGluZ3M6Cj4KPiAtICAgW1IgZm9yIERhdGEgU2NpZW5jZSAtIENoYXB0ZXIg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