Processing .Rnw files through knitr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The file 'knitDemo.Rnw' that is in this directory can be used by way of example. The document 'knitDemo.pdf' that is generated from it is intended as a brief introduction to knitr. First ensure that the knitr package and dependencies is installed. Then place the file 'knitDemo.Rnw' in the directory that will be the R working directory. Then start up R and load the knitr package: library("knitr") Then type knit("knitDemo.Rnw") This processes the file 'knitDemo.Rnw' to create, in the working directory, the file 'knitDemo.tex'. The final step is the creation, from 'knitDemo.tex', of a pdf file; for this the file demo-code.tex must be in the working directory. Use the program 'pdflatex', or an equivalent, for this purpose. [It is an easy matter to dispense with the need to have the file 'demo-code.tex' in your working directory. Either remove the line \input{demo-code.tex} from the file 'knitDemo.Rnw' before you process it through the knit comamnd, or remove this line from the file 'knitDemo.tex' that is generated, before proceeding to creation of the pdf.] What is knitr and what is Sweave? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'knitr' offers a modified version of the earlier Sweave markup syntax. There are a number of simplifications and useful enhancements relative to Sweave. To quote from the help file for Sweave() "'Sweave' provides a flexible framework for mixing text and S code for automatic report generation. The basic idea is to replace the S code with its output, such that the final document only contains the text and the output of the statistical anlysis. [It allows] automatic generation of reports by mixing word processing markup (like latex) and S code. The S code gets replaced by its output (text or graphs) in the final markup file. This allows to re-generate a report if the input data change and documents the code to reproduce the analysis in the same file that also produces the report." The Sweave syntax is based on the Noweb literate syntax. For further details and documentation for knitr, see the references given on the help page for 'knit'. John Maindonald March 7, 2013.