Skip to contents

Split divides and incidence2 object in to it's underlying groupings (count variable and optionally groups).

Usage

# S3 method for class 'incidence2'
split(x, f, drop, ...)

Arguments

x

An incidence2 object.

f

Not used. Present only for generic compatibility.

drop

Not used. Present only for generic compatibility.

...

Not used. Present only for generic compatibility.

Value

A list of tibbles contained the split data. This list also has a "key" attribute which is a tibble with rows corresponding to the grouping of each split.

See also

vctrs::vec_split() on which split.incidence2() is built.

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") |>
        split()
}
#> [[1]]
#> # A tibble: 53 × 4
#>    date_index hospital          count_variable count
#>    <isowk>    <fct>             <chr>          <int>
#>  1 2014-W15   Military Hospital date_of_onset      1
#>  2 2014-W19   Military Hospital date_of_onset      5
#>  3 2014-W20   Military Hospital date_of_onset      4
#>  4 2014-W21   Military Hospital date_of_onset      3
#>  5 2014-W22   Military Hospital date_of_onset      2
#>  6 2014-W23   Military Hospital date_of_onset      2
#>  7 2014-W24   Military Hospital date_of_onset      4
#>  8 2014-W25   Military Hospital date_of_onset      1
#>  9 2014-W26   Military Hospital date_of_onset      3
#> 10 2014-W27   Military Hospital date_of_onset      4
#> # ℹ 43 more rows
#> 
#> [[2]]
#> # A tibble: 54 × 4
#>    date_index hospital           count_variable count
#>    <isowk>    <fct>              <chr>          <int>
#>  1 2014-W16   Connaught Hospital date_of_onset      1
#>  2 2014-W18   Connaught Hospital date_of_onset      1
#>  3 2014-W19   Connaught Hospital date_of_onset      3
#>  4 2014-W20   Connaught Hospital date_of_onset      2
#>  5 2014-W21   Connaught Hospital date_of_onset      5
#>  6 2014-W22   Connaught Hospital date_of_onset      4
#>  7 2014-W23   Connaught Hospital date_of_onset      6
#>  8 2014-W24   Connaught Hospital date_of_onset      6
#>  9 2014-W25   Connaught Hospital date_of_onset     12
#> 10 2014-W26   Connaught Hospital date_of_onset      8
#> # ℹ 44 more rows
#> 
#> [[3]]
#> # A tibble: 53 × 4
#>    date_index hospital count_variable count
#>    <isowk>    <fct>    <chr>          <int>
#>  1 2014-W17   other    date_of_onset      3
#>  2 2014-W19   other    date_of_onset      1
#>  3 2014-W20   other    date_of_onset      5
#>  4 2014-W21   other    date_of_onset      1
#>  5 2014-W22   other    date_of_onset      3
#>  6 2014-W23   other    date_of_onset      3
#>  7 2014-W24   other    date_of_onset      2
#>  8 2014-W25   other    date_of_onset      5
#>  9 2014-W26   other    date_of_onset      2
#> 10 2014-W27   other    date_of_onset      9
#> # ℹ 43 more rows
#> 
#> [[4]]
#> # A tibble: 50 × 4
#>    date_index hospital                                     count_variable count
#>    <isowk>    <fct>                                        <chr>          <int>
#>  1 2014-W18   Princess Christian Maternity Hospital (PCMH) date_of_onset      1
#>  2 2014-W19   Princess Christian Maternity Hospital (PCMH) date_of_onset      1
#>  3 2014-W20   Princess Christian Maternity Hospital (PCMH) date_of_onset      1
#>  4 2014-W21   Princess Christian Maternity Hospital (PCMH) date_of_onset      2
#>  5 2014-W22   Princess Christian Maternity Hospital (PCMH) date_of_onset      4
#>  6 2014-W25   Princess Christian Maternity Hospital (PCMH) date_of_onset      3
#>  7 2014-W27   Princess Christian Maternity Hospital (PCMH) date_of_onset      4
#>  8 2014-W28   Princess Christian Maternity Hospital (PCMH) date_of_onset      2
#>  9 2014-W29   Princess Christian Maternity Hospital (PCMH) date_of_onset      7
#> 10 2014-W30   Princess Christian Maternity Hospital (PCMH) date_of_onset      5
#> # ℹ 40 more rows
#> 
#> [[5]]
#> # A tibble: 51 × 4
#>    date_index hospital        count_variable count
#>    <isowk>    <fct>           <chr>          <int>
#>  1 2014-W18   Rokupa Hospital date_of_onset      1
#>  2 2014-W19   Rokupa Hospital date_of_onset      1
#>  3 2014-W20   Rokupa Hospital date_of_onset      1
#>  4 2014-W22   Rokupa Hospital date_of_onset      2
#>  5 2014-W23   Rokupa Hospital date_of_onset      2
#>  6 2014-W24   Rokupa Hospital date_of_onset      1
#>  7 2014-W25   Rokupa Hospital date_of_onset      1
#>  8 2014-W27   Rokupa Hospital date_of_onset      1
#>  9 2014-W28   Rokupa Hospital date_of_onset      5
#> 10 2014-W29   Rokupa Hospital date_of_onset      4
#> # ℹ 41 more rows
#> 
#> attr(,"key")
#> # A tibble: 5 × 2
#>   count_variable hospital                                    
#>   <chr>          <fct>                                       
#> 1 date_of_onset  Military Hospital                           
#> 2 date_of_onset  Connaught Hospital                          
#> 3 date_of_onset  other                                       
#> 4 date_of_onset  Princess Christian Maternity Hospital (PCMH)
#> 5 date_of_onset  Rokupa Hospital