This function pools incidence across all groups of an incidence object. The resulting incidence() object will contains counts summed over all groups present in the input.

pool(x)

Arguments

x

An 'incidence' object.

See also

The incidence() function to generate the 'incidence' objects.

Examples

dat <- as.integer(c(0,1,2,2,3,5,7)) group <- factor(c(1, 2, 3, 3, 3, 3, 1)) i <- incidence(dat, groups = group) i
#> <incidence object> #> [7 cases from days 0 to 7] #> [3 groups: 1, 2, 3] #> #> $counts: matrix with 8 rows and 3 columns #> $n: 7 cases in total #> $dates: 8 dates marking the left-side of bins #> $interval: 1 day #> $timespan: 8 days #> $cumulative: FALSE #>
i$counts
#> 1 2 3 #> [1,] 1 0 0 #> [2,] 0 1 0 #> [3,] 0 0 2 #> [4,] 0 0 1 #> [5,] 0 0 0 #> [6,] 0 0 1 #> [7,] 0 0 0 #> [8,] 1 0 0
## pool all groups pool(i)
#> <incidence object> #> [7 cases from days 0 to 7] #> #> $counts: matrix with 8 rows and 1 columns #> $n: 7 cases in total #> $dates: 8 dates marking the left-side of bins #> $interval: 1 day #> $timespan: 8 days #> $cumulative: FALSE #>
pool(i)$counts
#> [,1] #> [1,] 1 #> [2,] 1 #> [3,] 2 #> [4,] 1 #> [5,] 0 #> [6,] 1 #> [7,] 0 #> [8,] 1
## pool only groups 1 and 3 pool(i[,c(1,3)])
#> <incidence object> #> [6 cases from days 0 to 7] #> #> $counts: matrix with 8 rows and 1 columns #> $n: 6 cases in total #> $dates: 8 dates marking the left-side of bins #> $interval: 1 day #> $timespan: 8 days #> $cumulative: FALSE #>
pool(i[,c(1,3)])$counts
#> [,1] #> [1,] 1 #> [2,] 0 #> [3,] 2 #> [4,] 1 #> [5,] 0 #> [6,] 1 #> [7,] 0 #> [8,] 1