A characteristic is appended to the respective object right from the start. It is accessible throughout runtime and can also change if a rule chooses to do so. However, compared to a variable, it is not calculated/determined in each iteration.
If you need to roll out a characteristic's distribution across a range of agents (e.g., a characteristic that's supposed to be normally distributed across a group or all of the agents), see distribute_characteristic_across_agents.
Usage
set_characteristic(
.tidyabm,
...,
.overwrite = FALSE,
.suppress_warnings = FALSE
)
# S3 method for tidyabm
set_characteristic(
.tidyabm,
...,
.overwrite = FALSE,
.suppress_warnings = FALSE
)Arguments
- .tidyabm
a
tidyabmobject- ...
<
data-masking> name-value pairs. The name lets you identify the characteristic. To avoid misunderstandings use unique names, also between agents and environments. Try to also avoid starting your name with a point/dot (.) because some internally added names use that pattern. Good names also do not have any whitespace and are all lowercase; use underscores to separate any words. It is recommended to also avoid the use of minus signs. Hence, a good characteristic name looks likethis_is_a_great_name. The value is treated as a single value (e.g., a character, numeric, logical, vector ...).- .overwrite
if
FALSE(the default), characteristics with the same name will not be overwritten (a warning will be issued)- .suppress_warnings
if
TRUE,.overwritewill not yield any warnings; default is FALSE, though
Examples
create_grid_environment(seed = 3, size = 5) %>%
set_characteristic(condition = 'small')
#> # A tibble: 0 × 0
#> # ABM grid environment
#> * 5x5, 0 agents
#> * 1 environment characteristic(s),
#> * 0 environment variable(s),
#> * 0 environment rule(s),
#> * not initiated
create_agent() %>%
set_characteristic(age = 15)
#> # A tibble: 1 × 1
#> age
#> * <dbl>
#> 1 15
#> # ABM agent
#> * 1 agent characteristic(s),
#> * 0 agent variable(s),
#> * 0 agent rule(s),
create_agent() %>%
set_characteristic(age = 15,
gender = 'm')
#> # A tibble: 1 × 2
#> age gender
#> * <dbl> <chr>
#> 1 15 m
#> # ABM agent
#> * 2 agent characteristic(s),
#> * 0 agent variable(s),
#> * 0 agent rule(s),
create_agent() %>%
set_characteristic(embed_vector = c(23.2, 12.4, 4.2, -3.2, 13.2, -0.1))
#> # A tibble: 1 × 1
#> embed_vector
#> * <list>
#> 1 <dbl [6]>
#> # ABM agent
#> * 1 agent characteristic(s),
#> * 0 agent variable(s),
#> * 0 agent rule(s),