ABSTRACT

The knitr package is a general-purpose literate programming engine — it supports document formats including HTML, and Markdown, and programming languages such as R, Python, awk, C++, and shell scripts. This chapter discusses how to generate reports quickly from pure R scripts, which can be useful who do not know anything about dynamic documents. If a user only has basic knowledge of R but knows nothing about knitr, or one does not want to write anything other than an R script, it is also possible to generate a quick report from this R script using the stitch() function. The basic idea of stitch() is that knitr provides a template of the source document with some default settings, so that the user only needs to feed this template with an R script; then knitr will compile the template to a report. Apparently the function knit() is for weaving, and the corresponding tangling function is purl() in knitr.