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.
install.packages("knitr")
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.
summary(cars)
- Open an new .Rmd script and save it as inflammation_report.Rmd
- 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.
- Add a few notes describing what the code does and what the main findings are.
KNIT
and view the html