Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_counts

Get counts from an incidence object


Description

Get counts from an incidence object

Usage

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

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"))
})}

incidence

Compute, Handle, Plot and Model Incidence of Dated Events

v1.7.3
MIT + file LICENSE
Authors
Thibaut Jombart [aut], Zhian N. Kamvar [aut] (<https://orcid.org/0000-0003-1458-7108>), Rich FitzJohn [aut], Tim Taylor [cre] (<https://orcid.org/0000-0002-8587-7113>), Jun Cai [ctb] (<https://orcid.org/0000-0001-9495-1226>), Sangeeta Bhatia [ctb], Jakob Schumacher [ctb], Juliet R.C. Pulliam [ctb] (<https://orcid.org/0000-0003-3314-8223>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.