Learn R Programming

epichains (version 0.1.1)

aggregate.epichains: Aggregate cases in <epichains> objects by "generation" or "time", if present

Description

This function provides a quick way to create a time series of cases over generation or time (if generation_time was specified) from simulated <epichains> objects.

Usage

# S3 method for epichains
aggregate(x, by = c("time", "generation"), ...)

Value

A <data.frame> object of cases by by.

Arguments

x

An <epichains> object.

by

The variable to aggregate by; A character string with options "time" and "generation".

...

Not used.

Author

James M. Azam

Examples

Run this code
set.seed(32)
chains <- simulate_chains(
  n_chains = 10,
  statistic = "size",
  offspring_dist = rpois,
  stat_threshold = 10,
  generation_time = function(n) rep(3, n),
  lambda = 2
)
chains

# Aggregate cases per time
cases_per_time <- aggregate(chains, by = "time")
head(cases_per_time)

# Aggregate cases per generation
cases_per_gen <- aggregate(chains, by = "generation")
head(cases_per_gen)

Run the code above in your browser using DataLab