11

Language Engines

We can work with a lot of languages and tools in knitr, including but not limited to R, although knitr is an R package and has to be run within the R environment in the first place. Currently knitr supports Python, Ruby, Haskell, awk/gawk, sed, shell scripts, Perl, SAS, TikZ, Graphviz, and C++, etc. We have to install the corresponding software package in advance to use an engine.

11.1    Design

Like chunk hooks, all language engines are essentially R functions in knitr. These functions pass the code chunk to external programs, run the code there, get the results back, and write to the output. In most cases, the code is passed to external programs via the system() function. For example, we can pass code to bash via the ...

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.