Learn R Programming

incidence2 (version 2.6.2)

regroup: Regroup 'incidence' objects

Description

This function regroups an incidence2 object across the specified groups. The resulting incidence2 object will contains counts aggregated over the specified groups. The only difference between regroup() and regroup_() is that the latter is built on top of tidy-select semantics for the group input.

Usage

regroup(x, groups = NULL)

regroup_(x, groups = NULL)

Arguments

x

<incidence2> object.

groups

character for regroup() or tidy-select for regroup_().

The groups to sum over.

If NULL (default) then the function returns the corresponding object with no groupings.

Examples

Run this code
.old <- data.table::setDTthreads(2)
if (requireNamespace("outbreaks", quietly = TRUE)) {
    data(ebola_sim_clean, package = "outbreaks")
    dat <- ebola_sim_clean$linelist
    i <- incidence(
        dat,
        date_index = "date_of_onset",
        groups = c("gender", "hospital")
    )
    regroup(i)
    regroup_(i)
    regroup(i, "hospital")
    regroup_(i, hospital)
}
data.table::setDTthreads(.old)

Run the code above in your browser using DataLab