subset: Subsetting 'incidence' objects

subset.incidenceR Documentation

Subsetting 'incidence' objects

Description

Two functions can be used to subset incidence objects. The function subset permits to retain dates within a specified range and, optionally, specific groups. The operator "[" can be used as for matrices, using the syntax x[i,j] where 'i' is a subset of dates, and 'j' is a subset of groups.

Usage

## S3 method for class 'incidence'
subset(x, ..., from = min(x$dates), to = max(x$dates), groups = TRUE)

## S3 method for class 'incidence'
x[i, j]

Arguments

x

An incidence object, generated by the function incidence().

...

Further arguments passed to other methods (not used).

from

The starting date; data strictly before this date are discarded.

to

The ending date; data strictly after this date are discarded.

groups

(optional) The groups to retained, indicated as subsets of the columns of x$counts.

i

a subset of dates to retain

j

a subset of groups to retain

Author(s)

Thibaut Jombart thibautjombart@gmail.com

See Also

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

Examples

## example using simulated dataset
if(require(outbreaks)) { withAutoprint({
  onset <- ebola_sim$linelist$date_of_onset

  ## weekly incidence
  inc <- incidence(onset, interval = 7)
  inc
  inc[1:10] # first 10 weeks
  plot(inc[1:10])
  inc[-c(11:15)] # remove weeks 11-15
  plot(inc[-c(11:15)])
})}


incidence documentation built on June 22, 2024, 10:35 a.m.