The knitr package [@R-knitr] is an alternative tool to Sweave based on a different design with more features. This document is not an introduction, but only serves as a placeholder to guide you to the real manuals, which are available on the package website http://yihui.name/knitr[e.g. the main manual and the graphics manual], and remember to read the help pages of functions in this package. There is a book [@xie2013] for this package, but it may not be useful to those who prefer digging out information on the web.

Anyway, here is a code chunk that shows you can compile vignettes with knitr as well using R 3.0.x, which supports non-Sweave vignettes:

rnorm(5)
## [1]  0.6907044 -1.3429614  0.7039870 -0.0001179 -1.4191240
df=data.frame(y=rnorm(100), x=1:100)
summary(lm(y~x, data=df))
## 
## Call:
## lm(formula = y ~ x, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.9774 -0.5087 -0.0349  0.5450  3.0211 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)  9.17e-03   1.94e-01    0.05     0.96
## x           -2.61e-05   3.33e-03   -0.01     0.99
## 
## Residual standard error: 0.963 on 98 degrees of freedom
## Multiple R-squared:  6.24e-07,   Adjusted R-squared:  -0.0102 
## F-statistic: 6.11e-05 on 1 and 98 DF,  p-value: 0.994

References