Learn R Programming

epiworldR (version 0.8.2.0)

agents: Agents in epiworldR

Description

These functions provide read-access to the agents of the model. The get_agents function returns an object of class epiworld_agents which contains all the information about the agents in the model. The get_agent function returns the information of a single agent. And the get_state function returns the state of a single agent.

Usage

get_agents(model, ...)

# S3 method for epiworld_model get_agents(model, ...)

# S3 method for epiworld_agents [(x, i)

# S3 method for epiworld_agent print(x, compressed = FALSE, ...)

# S3 method for epiworld_agents print(x, compressed = TRUE, max_print = 10, ...)

get_state(x)

Value

  • The get_agents function returns an object of class epiworld_agents.

  • The [ method returns an object of class epiworld_agent.

  • The print function returns information about each individual agent of class epiworld_agent.

  • The get_state function returns the state of the epiworld_agents object.

Arguments

model

An object of class epiworld_model.

...

Ignored

x

An object of class epiworld_agents

i

Index (id) of the agent (from 0 to n-1)

compressed

Logical scalar. When FALSE, it prints detailed information about the agent.

max_print

Integer scalar. Maximum number of agents to print.

See Also

agents

Examples

Run this code

model_sirconn <- ModelSIRCONN(
  name                = "COVID-19",
  n                   = 10000,
  prevalence          = 0.01,
  contact_rate        = 5,
  transmission_rate   = 0.4,
  recovery_rate       = 0.95
)

run(model_sirconn, ndays = 100, seed = 1912)

x <- get_agents(model_sirconn) # Storing all agent information into object of
# class epiworld_agents

print(x, compressed = FALSE, max_print = 5) # Displaying detailed information of
# the first 5 agents using
# compressed=F. Using compressed=T
# results in less-detailed
# information about each agent.

x[0] # Print information about the first agent. Substitute the agent of
# interest's position where '0' is.

Run the code above in your browser using DataLab