Skip to contents

This function regroups an <incidence2> object across the specified groups. The resulting <incidence2> object will contains counts summed over the groups present in the input. It differs from regroup() only in support for <tidy-select> semantics in the groups argument.

Usage

regroup_(x, groups = NULL)

Arguments

x

<incidence2> object.

groups

<tidyselect>

The groups to sum over.

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

See also

regroup() for a version without tidyselect semantics. This may be preferable for programatic usage.

Examples

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, hospital)
}
#> # incidence:  1,635 x 4
#> # count vars: date_of_onset
#> # groups:     hospital
#>    date_index hospital                                     count_variable count
#>    <date>     <fct>                                        <chr>          <int>
#>  1 2014-04-07 Military Hospital                            date_of_onset      1
#>  2 2014-04-15 Connaught Hospital                           date_of_onset      1
#>  3 2014-04-21 other                                        date_of_onset      2
#>  4 2014-04-25 NA                                           date_of_onset      1
#>  5 2014-04-26 other                                        date_of_onset      1
#>  6 2014-04-27 NA                                           date_of_onset      1
#>  7 2014-05-01 Princess Christian Maternity Hospital (PCMH) date_of_onset      1
#>  8 2014-05-01 Rokupa Hospital                              date_of_onset      1
#>  9 2014-05-03 Connaught Hospital                           date_of_onset      1
#> 10 2014-05-04 NA                                           date_of_onset      1
#> # ℹ 1,625 more rows