register_engine: Register .NET knitr engine

View source: R/knitr_engine.R

register_engineR Documentation

Register .NET knitr engine

Description

Registers dotnet knitr engine for use in R Markdown chunks.

Usage

register_engine()

Engine options

Options (and their defaults) that can be set in engine.opts:

name

application name ("myApp" by default)

dir

path to the application source, can be existing application

file

source file name ("Program" by default)

run_app

TRUE by default; set to FALSE to not run application

language

"C#" or "F#"; if omitted uses getOption("dotnet.language") which is C# by default

add_packages

NuGet packages the code depends on, in addition to those listed in getOption("dotnet.language") (if any)

Caching

If cache=TRUE in chunk options, engine.opts$dir and engine.opts$file will be preset and cannot be overridden. Caching only works for single-chunk programs.

Multi-chunk programs

In cases where you want to split your program across multiple chunks, there are a few things to keep in mind. Most importantly is that because this is accomplished by specifying engine.opts(name = "appName", dir = "/path/to/app"), you will need to manually manage that directory. A new application will be created there the first time the document is knit, but will not be deleted after the fact.

If an application is not ready to be run, set engine.opts(run_app = FALSE).

Languages

When creating a new DotNetApp, it defaults to the programming language set in dotnet.language option, which is C# by default. This can be overridden by specifying language = "F#" when creating a new instance or by changing the default via options(dotnet.language = "F#"), to avoid having to specify it every time.

Packages

Packages can be added to the app after it was created by using add_package method. Packages can be added at create time by specifying them with the packages argument when calling $new().

To avoid having to add packages manually every time when creating a new app or if you have multiple chunks using the dotnet knitr engine and they all depend on the same set of packages, you can set a character vector of package names in the dotnet.packages option. Those packages will be added automatically to all newly created apps.

References

Registering a custom language engine


bearloga/dotnet documentation built on April 5, 2022, 5:33 p.m.