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.66523379 -0.33592059 0.01888257 0.37322770 -0.65483094
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.48084 -0.67888 0.01392 0.63989 2.22222
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.149746 0.188735 0.793 0.4295
## x -0.007580 0.003245 -2.336 0.0215 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9366 on 98 degrees of freedom
## Multiple R-squared: 0.05275, Adjusted R-squared: 0.04309
## F-statistic: 5.457 on 1 and 98 DF, p-value: 0.02152