Description Usage Arguments Details Value Examples
View source: R/agent-to-aggregate.R
This function converts data on an agent-based level (1 row = 1 agent)
relative when an agent is in each state and aggregates it, so that the user
can know how many agents are in each state at a given time point (integer
based). This function takes grouped_df
data.frame
s (from
dplyr) and aggregates within grouping parameters and also
provides the columns associated with the grouping.
1 2 3 4 5 6 7 8 9 |
agents |
grouped data.frame with individual agent information |
states |
Name-variable pairs of the form
|
death |
string for column with death time information (default
|
birth |
string for column with birth time information (default
|
min_max_time |
vector (length 2) of minimum and maximum integer time,
the second value can be |
integer_time_expansion |
boolean if every integer time point in the
range of |
note that all parameters related to name columns can also be in a
string format. More details can be found in agents_to_aggregate
's
documentation.
grouped dataset with aggregated information per group, We label
classes "X{i}
" for i in 0:(length(states))
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(dplyr)
max_time <- 100
agents_g <- hagelloch_raw %>%
filter(SEX %in% c("female", "male")) %>% group_by(SEX)
sir_group <- agents_to_aggregate(agents_g, states = c(tI, tR),
min_max_time = c(0, max_time))
agents <- agents_g %>%
filter(SEX == "female") %>% ungroup()
sir_group1 <- agents_to_aggregate(agents, states = c(tI, tR),
min_max_time = c(0, max_time))
sir_group_1 <- sir_group %>% filter(SEX == "female")
assertthat::are_equal(sir_group1,
sir_group_1 %>% ungroup %>% select(t, X0, X1, X2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.