This function creates a custom knitr engine for executing Genstat code by connecting to a Genstat server over a socket. The engine sends Genstat code, receives output, and renders it in R Markdown documents with support for formatted tables, warnings, and embedded plots.

gs.engine(
  host = Sys.getenv("GENSTAT_HOST", "localhost"),
  port = as.integer(Sys.getenv("GENSTAT_PORT", "8085")),
  timeout = 1L
)

Arguments

host

A character string specifying the host name or IP address of the Genstat server. Defaults to `"localhost"` or the environment variable `GENSTAT_HOST`.

port

An integer specifying the port number to connect to on the Genstat server. Defaults to `8085` or the environment variable `GENSTAT_PORT`.

timeout

numeric, number of seconds to wait if no response is coming.

Value

A function that can be registered as a knitr engine (e.g., via `knitr::knit_engines$set(gs = gs.engine())`)

Examples

if (FALSE) { # \dontrun{
knitr::knit_engines$set(gs = gs.engine())
} # }