Skip to contents

Method for dplyr::summarise that implicitly accounts for the inherent grouping structure of incidence2 objects.

Usage

# S3 method for class 'incidence2'
summarise(.data, ..., .by, .groups)

Arguments

.data

An incidence2 object.

...

<data-masking> Name-value pairs. The name gives the name of the column in the output.

The value can be:

  • A vector of length 1, which will be recycled to the correct length.

  • A vector the same length as the current group (or the whole data frame if ungrouped).

  • NULL, to remove the column.

  • A data frame or tibble, to create multiple columns in the output.

.by

Not used as grouping structure implicit.

.groups

Not used.

Value

A tibble.

See also

dplyr::summarise for the underlying grouping.

Examples

if (requireNamespace("outbreaks", quietly = TRUE)) {
    data(ebola_sim_clean, package = "outbreaks")
    ebola_sim_clean$linelist |>
        subset(!is.na(hospital)) |>
        incidence_(date_of_onset, hospital, interval = "isoweek") |>
        summarise(model = list(glm(count ~ date_index, family = "poisson")))
}
#> # A tibble: 5 × 3
#>   count_variable hospital                                     model 
#>   <chr>          <fct>                                        <list>
#> 1 date_of_onset  Military Hospital                            <glm> 
#> 2 date_of_onset  Connaught Hospital                           <glm> 
#> 3 date_of_onset  other                                        <glm> 
#> 4 date_of_onset  Princess Christian Maternity Hospital (PCMH) <glm> 
#> 5 date_of_onset  Rokupa Hospital                              <glm>