Learn R Programming

SimInf (version 5.1.0)

C_code: Extract the C code from an mparse object

Description

Extract the C code from an mparse object

Usage

C_code(model, pkg)

# S4 method for SimInf_mparse,missing C_code(model)

# S4 method for SimInf_mparse,character C_code(model, pkg)

Arguments

model

The mparse object to extract the C code from.

pkg

Character vector. If the C could should be used in a package named pkg, the function modifies the C code to facilitate adding the code to the package. Default is to not use this argument and return the C code unmodified.

Value

Character vector with C code for the model.

Examples

Run this code
# NOT RUN {
## Use the model parser to create a 'SimInf_mparse' object that
## expresses an SIR model, where 'b' is the transmission rate and
## 'g' is the recovery rate.
m <- mparse(c("S -> b*S*I/(S+I+R) -> I", "I -> g*I -> R"),
            c("S", "I", "R"), b = 0.16, g = 0.077)

## View the C code.
C_code(m)

## Modify the C code for a package named "XYZ"
C_code(m, "XYZ")
# }

Run the code above in your browser using DataLab