odin_parse: Parse an odin model

View source: R/odin_parse.R

odin_parseR Documentation

Parse an odin model


Parse an odin model, returning an intermediate representation. The odin_parse_ version is a "standard evaluation" escape hatch.


odin_parse(x, type = NULL, options = NULL)

odin_parse_(x, options = NULL, type = NULL)



An expression, character vector or filename with the odin code


An optional string indicating the the type of input - must be one of expression, file or text if provided. This skips the type detection code used by odin and makes validating user input easier.


odin options; see odin_options. The primary options that affect the parse stage are validate and pretty.


A schema for the intermediate representation is available in the package as schema.json. It is subject to change at this point.

See Also

odin_validate, which wraps this function where parsing might fail, and odin_build for building odin models from an intermediate representation.


# Parse a model of exponential decay
ir <- odin::odin_parse({
  deriv(y) <- -0.5 * y
  initial(y) <- 1

# This is odin's intermediate representation of the model

# If parsing odin models programmatically, it is better to use
# odin_parse_; construct the model as a string, from a file, or as a
# quoted expression:
code <- quote({
  deriv(y) <- -0.5 * y
  initial(y) <- 1


odin documentation built on April 28, 2022, 9:05 a.m.