Learn R Programming

SimInf (version 5.0.0)

infected: Infected

Description

Extracts the number of infected

Usage

infected(model, ...)

# S4 method for SEIR infected(model, i = NULL, ...)

# S4 method for SIR infected(model, i = NULL, ...)

# S4 method for SISe infected(model, i = NULL, ...)

# S4 method for SISe3 infected(model, age = 1:3, i = NULL, ...)

# S4 method for SISe3_sp infected(model, age = 1:3, i = NULL, ...)

# S4 method for SISe_sp infected(model, i = NULL, ...)

Arguments

model

The model to extract the infected from

...

Additional arguments affecting the measure

i

Indices specifying the nodes to include when extracting the number of infected. Default is NULL, which includes all nodes.

age

For models with age categories, the age category to extract.

Examples

Run this code
# NOT RUN {
## Create an 'SIR' model with 5 nodes and initialize
## it to run over 10 days.
u0 <- data.frame(S = rep(99, 5), I = rep(1, 5), R = rep(0, 5))
model <- SIR(u0 = u0, tspan = 1:10, beta = 0.16, gamma = 0.077)

## Run the model and save the result
result <- run(model, threads = 1, seed = 1)

## Extract the number of infected individuals in each
## node after each time step in the simulation
infected(result)

## Extract the number of infected individuals in the
## first node after each time step in the simulation
infected(result, i = 1)

## Extract the number of infected individuals in the
## first and fifth node after each time step in the simulation
infected(result, i = c(1, 5))
# }

Run the code above in your browser using DataLab