| add_entities_from_dataframe | R Documentation |
Helper function that facilities creating entities and adding them to
models. It is a wrapper of add_entity().
add_entities_from_dataframe(model, entities, col_name, col_number, ...)
model |
An epiworld_model object. |
entities |
A |
col_name |
The name of the column in |
col_number |
The name of the column in |
... |
Further arguments passed to |
Inivisible the model with the added entities.
# Start off creating three entities.
# Individuals will be distributed randomly between the three.
entities <- data.frame(
name = c("Pop 1", "Pop 2", "Pop 3"),
size = rep(3e3, 3)
)
# Row-stochastic matrix (rowsums 1)
cmatrix <- c(
c(0.9, 0.05, 0.05),
c(0.1, 0.8, 0.1),
c(0.1, 0.2, 0.7)
) |> matrix(byrow = TRUE, nrow = 3)
flu_model <- ModelSIRMixing(
name = "Flu",
n = 9e3,
prevalence = 1 / 9e3,
contact_rate = 20,
transmission_rate = 0.1,
recovery_rate = 1 / 7,
contact_matrix = cmatrix
) |>
add_entities_from_dataframe(
entities = entities,
col_name = "name",
col_number = "size",
# This is passed to `add_entity()`
as_proportion = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.