Method for tidyr::nest that implicitly accounts for the inherent grouping structure of incidence2 objects.
Usage
# S3 method for class 'incidence2'
nest(.data, ..., .by, .key, .names_sep)
Arguments
- .data
An incidence2 object.
- ...
Not used.
- .by
Not used.
- .key
The name of the resulting nested column. Only applicable when
...
isn't specified, i.e. in the case ofdf %>% nest(.by = x)
.If
NULL
, then"data"
will be used by default.- .names_sep
Not used.
Value
A nested tibble with rows corresponding to the count variable and (optionally) group columns of the input object.
See also
tidyr::nest for the underlying generic.
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") |>
nest()
}
#> # A tibble: 5 × 3
#> count_variable hospital data
#> <chr> <fct> <list>
#> 1 date_of_onset Military Hospital <tibble [53 × 2]>
#> 2 date_of_onset Connaught Hospital <tibble [54 × 2]>
#> 3 date_of_onset other <tibble [53 × 2]>
#> 4 date_of_onset Princess Christian Maternity Hospital (PCMH) <tibble [50 × 2]>
#> 5 date_of_onset Rokupa Hospital <tibble [51 × 2]>