knitr is an R package for dynamic report generation based on the concept of literate programming.
knitr is an r package for dynamic report generation based on the concept of literate-programming. That is, you can mix text, R code, and its output into a single document.
It combines features of sweave and related R packages like weaver and R2HTML. It has built-in support for cache, tikz graphics via the tikzDevice package, syntax highlighting via the highlight package and code reformatting via the formatR package.
Unlike Sweave, the document format for knitr does not have to be latex: html, markdown, asciidoc, restructuredtext and textile are also supported. Both the syntax and the output are customizable via pattern lists and hook functions respectively, for example, it is easy to make use of the listings package to mark up R code and output by setting up a series of output hooks. A rich set of chunk options and package options are documented in the package website. There are also demos showing possible applications of knitr.
Below is a "Hello World" output from knitr taken from the package manual:
Repositories
Vignettes
- Custom Print Methods
- Not an Introduction to knitr
- knitr Reference Card
- Display Tables with the DataTables Library
- Templating with knit_expand()
- An R HTML Vignette with knitr
- An R Markdown Vignette with knitr
- R Markdown with the Docco Classic Style
- R Markdown with the Docco Linear Style
Book
- Dynamic Documents with R and knitr (source for ch1–3) by Yihui Xie
Other resources
- Yihui Xie's knitr homepage
- Posts on R-bloggers
Related tags
- sweave is an earlier system for literate-progamming and reproducible-research in r.