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).
| 1 2 3 4 5 6 7 8 9 | 
| agents | 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.
dataset with aggregated information, 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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | library(dplyr)
agents <- EpiCompare::hagelloch_raw
# making babies
set.seed(5)
babies <- sample(nrow(agents),size = 5)
agents$tBIRTH <- NA
agents$tBIRTH[babies] <- agents$tI[babies] - 5
aggregate_b <- agents_to_aggregate(agents, states = c(tI, tR),
                                   death = NULL, birth = tBIRTH)
# looking at when babies where born:
agents %>% dplyr::filter(!is.na(.data$tBIRTH)) %>%
  dplyr::pull(.data$tBIRTH) %>% ceiling() %>% sort
# vs:
data.frame(counts = 1:nrow(aggregate_b),
           num_people = aggregate_b %>% select(-t) %>% apply(1, sum))
# including death
aggregate_d <- agents_to_aggregate(agents, states = c(tI, tR),
                                   death = tDEAD, birth = NULL)
# looking at when people died:
agents %>% dplyr::filter(!is.na(.data$tDEAD)) %>%
  dplyr::pull(.data$tDEAD) %>% ceiling() %>% sort
# vs:
data.frame(counts = 1:nrow(aggregate_d),
           num_people = aggregate_d %>% select(-t) %>% apply(1, sum))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.