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.4975 -0.8315 -2.0122 0.1123 0.8904
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.0392 -0.5964 0.0091 0.6487 2.0326
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.44947 0.19063 2.36 0.02 *
## x -0.00419 0.00328 -1.28 0.20
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.946 on 98 degrees of freedom
## Multiple R-squared: 0.0164, Adjusted R-squared: 0.00638
## F-statistic: 1.64 on 1 and 98 DF, p-value: 0.204