
Last chance! 50% off unlimited learning
Sale ends in
SimInf_model
objectExtract the C code from a SimInf_model
object
C_code(model, pkg = NULL)
The SimInf_model
object to extract the C code
from.
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.
Character vector with C code for the model.
# NOT RUN {
## 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)
## Modify the C code for a package named "XYZ"
C_code(model, "XYZ")
# }
Run the code above in your browser using DataLab