ABSTRACT

This chapter deals 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. Like chunk hooks, all language engines are essentially R functions in knitr. The chunk option engine can be used to specify the language engine for a chunk. Among all options there is one special option named code, which is the code (as a character string) of the current chunk and plays the central role in the language engine. Most languages and tools are supported through the system() interface. There are two simple language engines c and fortran for the C language and Fortran, respectively. C++, C, and Fortran belong to compiled languages, and there are other languages that are interpreted languages. For these languages, we can execute the code without compiling it.