Skip to contents

cumulate() computes the cumulative incidence over time for an incidence2 object.

Usage

cumulate(x)

Arguments

x

incidence2 object.

Examples

dat <- data.frame(
  dates = as.integer(c(0,1,2,2,3,5,7)),
  groups = factor(c(1, 2, 3, 3, 3, 3, 1))
)

i <- incidence(dat, date_index = "dates", groups = "groups")
cumulate(i)
#> # incidence:  6 x 4
#> # count vars: dates
#> # groups:     groups
#>   date_index groups count_variable cumulative_count
#> *      <int> <fct>  <chr>                     <int>
#> 1          0 1      dates                         1
#> 2          7 1      dates                         2
#> 3          1 2      dates                         1
#> 4          2 3      dates                         2
#> 5          3 3      dates                         3
#> 6          5 3      dates                         4