CT2DF: Contingency Table to Data Frame

Description Usage Arguments Value Author(s) See Also Examples

Description

Take a 2D contingency table and create a data frame representing the individual cases.

Usage

1
2
CT2DF(x, rn = row.names(x), cn = colnames(x), dfn = c("row.var",
  "col.var"))

Arguments

x

Contingency table as a matrix.

rn

Character vector of the row names.

cn

Character vector of the column names.

dfn

Character vector with 2 values for the variable representing the rows and columns.

Value

A data frame with two columns.

Author(s)

David Diez

See Also

MosaicPlot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
a <- matrix(
    c(459, 727, 854, 385, 99, 4198, 6245, 4821, 1634, 578),
    2,
    byrow = TRUE)
b <-
CT2DF(
    a,
    c("No", "Yes"),
    c("Excellent", "Very good", "Good", "Fair", "Poor"),
    c("coverage", "health_status"))
table(b)

OpenIntroStat/openintro-r-package documentation built on Aug. 12, 2019, 5:19 a.m.