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.8990942 -0.4277310 2.0601624 0.8860859 -1.8692605
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.26725 -0.89739 -0.01668 0.83130 2.82773
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.038826 0.233977 0.166 0.869
## x 0.000863 0.004023 0.215 0.831
##
## Residual standard error: 1.161 on 98 degrees of freedom
## Multiple R-squared: 0.0004695, Adjusted R-squared: -0.00973
## F-statistic: 0.04603 on 1 and 98 DF, p-value: 0.8306