add_history: Add history to Entity

Description Usage Arguments Examples

View source: R/Entity-functions.R

Description

Recording past events of entities allow them to have memory of their past experiences and actions. This can be later use, if requires, in future decision making processes. For example, the number of past fertility events may be a strong predictor of the next fertility for female individuals.

Usage

1
add_history(entity, ids, event, time = .get_sim_time(), id_col_as_list = FALSE)

Arguments

entity

an Entity or its inheritances object.

ids

a integer vector that contains ids of entities to record the event

event

a character value that denotes the event that is being recorded

time

a integer value that represent the time at which the event occured for the entities.

id_col_as_list

a logical value which indicates whether the id column should be stored as a list column. This significantly reduces the memory footprint of the history data with a higher cost for basic data manipulation since the data must be unnested to filter by entity ids.

Examples

1
2
3
create_toy_population()
add_history(pop$get("Individual"), ids = c(1:100), event = "test_event", time = 1)
pop$get("Individual")$get_data("history")

dymium-org/dymiumCore documentation built on July 18, 2021, 5:10 p.m.