newCounter {ABM}R Documentation

Create a logger of the Counter class

Description

When state changes occur, it is passed to each logger, which then change its value. At the specified time points in a run, the values of the logger are reported and recorded in a data.frame object, where the columns represent variables, and rows represent the observation at each time point given to each run. Each logger has a name, which becomes the the column name in the data.frame.

Arguments

name

the name of the counter, must be a length-1 character vector

from

a list specifying state of the agent, or a character or numeric value that is equivalent to list(from). please see the details section

to

a list (can be NULL) specifying the state of the agent after the state change, or a character or numeric value that is equivalent to list(from). please see the details section

initial

the initial value of the counter. Default to 0.

Details

if the argument "to" is not NULL, then the counter counts the transitions from "from" to "to". Otherwise, it counts the number of agents in a state that matches the "from" argument. Specifically, if the agent jumps to "from", then the count increases by 1. If the agents jumps away from "from", then the count decreases by 1.

Value

an external pointer that can be passed to the Simulation class' ⁠$addLogger⁠.


[Package ABM version 0.4.1 Index]