build_incidence() coerces an object to an incidence of events.

  groups = NULL,
  counts = NULL,
  na_as_group = TRUE,
  FUN = identity,
  args = list()



A data frame representing a linelist (or potentially a pre-aggregated dataset).


The time index(es) of the given data. Multiple inputs only make sense when x is a linelist, and in this situation, to avoid ambiguity, the vector must be named. These names will be used for the resultant count columns.


An optional vector giving the names of the groups of observations for which incidence should be grouped.


The count variables of the given data. If NULL (default) the data is taken to be a linelist of individual observations.


A logical value indicating if missing group values (NA) should treated as a separate category (TRUE) or removed from consideration (FALSE). Defaults to TRUE.


Function applied to the dates_index vectors before grouping. The first argument of FUN must work with a dates_index vector. Defaults to the identity function.


List of additional arguments passed to FUN.


An incidence_df`` object. This is a subclass of [tibble][tibble::tbl-df`] represents an aggregated count of observations. It will contain the following columns:

date_index: If the default interval of 1 day is used then this will be the dates of the given observations and given the name "date", otherwise, this will be values obtained from the specified date grouping with column name "date_index" (See Interval specification below).

  • count (or name of count variables): The aggregated observation counts.

  • groups (if specified): column(s) containing the categories of the given groups.