get_counts: Get counts from an incidence object

Description Usage Arguments Value Examples

View source: R/get_counts.R

Description

Get counts from an incidence object

Usage

1
2
3
4
get_counts(x, groups = NULL)

## S3 method for class '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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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"))
})}

reconhub/incidence documentation built on Nov. 18, 2020, 3:49 a.m.