C_code: Extract the C code from a 'SimInf_model' object

View source: R/C-generator.R

C_codeR Documentation

Extract the C code from a SimInf_model object

Description

Extract the C code from a SimInf_model object

Usage

C_code(model)

Arguments

model

The SimInf_model object to extract the C code from.

Value

Character vector with C code for the model.

Examples

## Use the model parser to create a 'SimInf_model' object that
## expresses an SIR model, where 'b' is the transmission rate and
## 'g' is the recovery rate.
model <- mparse(transitions = c("S -> b*S*I/(S+I+R) -> I", "I -> g*I -> R"),
                compartments = c("S", "I", "R"),
                gdata = c(b = 0.16, g = 0.077),
                u0 = data.frame(S = 99, I = 1, R = 0),
                tspan = 1:10)

## View the C code.
C_code(model)

SimInf documentation built on Jan. 23, 2023, 5:43 p.m.