5

Document Formats

The design of the knitr package is flexible enough to process any plain text documents in theory. Below are the three key components of the design:

1.  a source parser

2.  a code evaluator

3.  an output renderer

The parser parses the source document and identifies computer code chunks as well as inline code from the document; the evaluator executes the code and returns results; the renderer formats the results from computing in an appropriate format, which will finally be combined with the original documentation.

The code evaluator is independent of the document format, whereas the parser and the renderer have to take the document format into consideration. The former corresponds to the input syntax, and the latter is related ...

Get Dynamic Documents with R and knitr, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.