R: Engines of other languages

knit_engines {knitr} | R Documentation

## Engines of other languages

### Description

This object controls how to execute the code from languages other than R (when the chunk option `engine` is not `'R'`). Each component in this object is a function that takes a list of current chunk options (including the source code) and returns a character string to be written into the output.

### Usage

    knit_engines

### Format

An object of class `list` of length 4.

### Details

The engine function has one argument `options`: the source code of the current chunk is in `options$code`. Usually we can call external programs to run the code via `system2`. Other chunk options are also contained in this argument, e.g. `options$echo` and `options$eval`, etc.

In most cases, `options$engine` can be directly used in command line to execute the code, e.g. `python` or `ruby`, but sometimes we may want to specify the path of the engine program, in which case we can pass it through the `engine.path` option. For example, `engine='ruby', engine.path='/usr/bin/ruby1.9.1'`. Additional command line arguments can be passed through `options$engine.opts`, e.g. `engine='ruby', engine.opts='-v'`.

Below is a list of built-in language engines, retrieved via `knit_engines$get()`:

`List of 38 $ awk :function (options) $ bash :function (options) $ coffee :function (options) $ gawk :function (options) $ groovy :function (options) $ haskell :function (options) $ lein :function (options) $ mysql :function (options) $ node :function (options) $ octave :function (options) $ perl :function (options) $ psql :function (options) $ python :function (options) $ Rscript :function (options) $ ruby :function (options) $ sas :function (options) $ scala :function (options) $ sed :function (options) $ sh :function (options) $ stata :function (options) $ zsh :function (options) $ highlight:function (options) $ Rcpp :function (options) $ tikz :function (options) $ dot :function (options) $ c :function (options) $ fortran :function (options) $ fortran95:function (options) $ asy :function (options) $ cat :function (options) $ asis :function (options) $ stan :function (options) $ block :function (options) $ block2 :function (options) $ js :function (options) $ css :function (options) $ sql :function (options) $ go :function (options)`

### Note

The Leiningen engine `lein` requires lein-exec plugin; see https://github.com/yihui/knitr/issues/1176 for details.

### References

Usage: https://yihui.name/knitr/objects/; examples: https://yihui.name/knitr/demo/engines/

### Examples

    knit_engines$get("python")
    knit_engines$get("awk")
    names(knit_engines$get())

[Package knitr version 1.16 Index]