## Create an SIR model object.
model <- SIR(
u0 = data.frame(S = 99, I = 1, R = 0),
tspan = 1:100,
beta = 0.16,
gamma = 0.077
)
## Get the initial compartment state.
u0(model)
## Modify the initial state (e.g., add 10 infected individuals to
## node 1).
new_u0 <- u0(model)
new_u0[1, "I"] <- new_u0[1, "I"] + 10
## Create a new model with the modified initial state.
new_model <- SIR(
u0 = new_u0,
tspan = 1:100,
beta = 0.16,
gamma = 0.077
)
## Alternatively, update the existing model using the setter:
u0(model) <- new_u0
Run the code above in your browser using DataLab