knitr is an R package for dynamic report generation based on the concept of literate programming. It combines features of and related packages like pgfSweave, cacheSweave, 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, both HTML and markdown 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:

enter image description here

history | show excerpt | excerpt history