Engines of other languages

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.


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():

[results=verbatim]{str(knitr::knit_engines$get())} knit_engines$get("python") knit_engines$get("awk") names(knit_engines$get()) Usage:; examples: datasets


List of 4 $ get :function (name, default = FALSE, drop = TRUE) $ set :function (...) $ merge :function (values) $ restore:function (target = value)

  • knit_engines
Documentation reproduced from package knitr, version 1.7, License: GPL

Community examples

Looks like there are no examples yet.