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] -1.0421687  0.9124176  0.4645548 -0.5916581 -0.4661348
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 
## -2.47441 -0.68126 -0.07168  0.72768  2.94905 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept) -0.299957   0.196993  -1.523   0.1311  
## x            0.006453   0.003387   1.905   0.0597 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9776 on 98 degrees of freedom
## Multiple R-squared:  0.03572,    Adjusted R-squared:  0.02588 
## F-statistic: 3.631 on 1 and 98 DF,  p-value: 0.05966

References