-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07-knitr-R.Rmd
41 lines (32 loc) · 1.28 KB
/
07-knitr-R.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
---
layout: page
title: Programming with R
subtitle: Dynamic reports with knitr
minutes: 30
---
```{r, include = FALSE}
source("tools/chunk-options.R")
```
> ## Learning Objectives {.objectives}
>
> * To discover `knitr` and the generation of dynamic reports
`Knitr` is an R package that makes your code neat, pretty, and shows your notes, code, and output simultaneously in an `html` document. You create these documents in `.Rmd` files. You can write in `LateX` or `md`.
knitr extracts R code in the input document (.Rmd), evaluates it and writes the results to the output document (html). There are two types of R code: chunks (code as separate paragraphs) and inline R code.
```{r, eval=FALSE}
install.packages("knitr")
```
```{r}
library(knitr)
```
Restart RStudio.
Open a new `Rmd` file.
In Rmd, anything between lines that start and end with triple quotes ``` will be run as R code.
```{r}
summary(cars)
```
> ## Challenge - Using KnitR to produce a report {.challenge}
>
> 1. Open an new .Rmd script and save it as inflammation_report.Rmd
> 2. Copy and paste the code as embedded R chunks to read in the data and plot average inflammation, or the heat map that we created.
> 3. Add a few notes describing what the code does and what the main findings are.
> 4. `KNIT` and view the html