Skip to contents

Generates a contingency table given the 'from' and 'to' vectors.

Usage

ttable(from, to, levels = NULL, ...)

Arguments

from

A vector of infectors.

to

A vector of infectees.

levels

Optional. A vector of levels for the factors. Defaults to unique, sorted values of 'from' and 'to'.

...

Additional arguments to be passed to the 'table' function.

Value

A contingency table representing the counts of infectors (rows) and infectees (columns) in each group (level).

Examples

from <- c("A", "A", NA, "C", "C", "C")
to <- c("A", "B", "B", "C", "C", "C")
ttable(from, to)
#>     to
#> from A B C
#>    A 1 1 0
#>    B 0 0 0
#>    C 0 0 3