Learn R Programming

SimInf (version 10.0.0)

n_compartments: Determine the number of compartments in a model

Description

Determine the number of compartments in a model

Usage

n_compartments(model)

# S4 method for SimInf_model n_compartments(model)

Value

the number of compartments in the model.

Arguments

model

the model object to extract the number of compartments from.

Examples

Run this code
## Create an 'SIR' model with 100 nodes, with 99 susceptible,
## 1 infected and 0 recovered in each node.
u0 <- data.frame(S = rep(99, 100), I = rep(1, 100), R = rep(0, 100))
model <- SIR(u0 = u0, tspan = 1:10, beta = 0.16, gamma = 0.077)

## Display the number of compartments in the model.
n_compartments(model)

Run the code above in your browser using DataLab