Get counts from an incidence object

get_counts(x, groups = NULL)

# S3 method for incidence
get_counts(x, groups = NULL)

Arguments

x

an incidence object.

groups

if there are groups, use this to specify a group or groups to subset. Defaults to NULL indicating that all groups are returned.

Value

a matrix of counts where each row represents a date bin

Examples

if (require(outbreaks)) { withAutoprint({ dat <- ebola_sim$linelist$date_of_onset gend <- ebola_sim$linelist$gender i <- incidence(dat, interval = "week", groups = gend) ## Use with an object and no arguments gives the counts matrix head(get_counts(i)) ## Specifying a position or group name will return a matrix subset to that ## group head(get_counts(i, 1L)) head(get_counts(i, "f")) ## Specifying multiple groups allows you to rearrange columns head(get_counts(i, c("m", "f"))) ## If you want a vector, you can use drop drop(get_counts(i, "f")) })}
#> > dat <- ebola_sim$linelist$date_of_onset #> > gend <- ebola_sim$linelist$gender #> > i <- incidence(dat, interval = "week", groups = gend) #> > head(get_counts(i)) #> f m #> [1,] 1 0 #> [2,] 0 1 #> [3,] 4 1 #> [4,] 4 0 #> [5,] 9 3 #> [6,] 8 10 #> > head(get_counts(i, 1L)) #> f #> [1,] 1 #> [2,] 0 #> [3,] 4 #> [4,] 4 #> [5,] 9 #> [6,] 8 #> > head(get_counts(i, "f")) #> f #> [1,] 1 #> [2,] 0 #> [3,] 4 #> [4,] 4 #> [5,] 9 #> [6,] 8 #> > head(get_counts(i, c("m", "f"))) #> m f #> [1,] 0 1 #> [2,] 1 0 #> [3,] 1 4 #> [4,] 0 4 #> [5,] 3 9 #> [6,] 10 8 #> > drop(get_counts(i, "f")) #> [1] 1 0 4 4 9 8 8 9 13 7 15 12 11 18 35 38 45 45 57 #> [20] 65 74 115 123 167 156 160 135 135 117 129 111 91 75 79 69 67 62 62 #> [39] 41 47 63 49 42 44 36 40 38 38 28 29 34 29 18 27 18 10