Prints a 2-way contingency table along with percentages, marginal, and conditional distributions.

table2d_summary(object, margins = TRUE, percentages = FALSE,
  conditionals = c("none", "row", "column"), chisq.test = TRUE, ...)

Arguments

object

a \(r \times c\)-contingency table

margins

if TRUE, marginal distributions are computed.

percentages

if TRUE, relative frequencies are computed.

conditionals

if not "none", the conditional distributions, given the row/column factor, are computed.

chisq.test

if TRUE, a chi-squared test of independence is carried out.

...

currently not used.

Value

Returns invisibly a \(r \times c \times k\) table, \(k\) depending on the amount of choices (at most 3).

Author

David Meyer David.Meyer@R-project.org

Examples

data("UCBAdmissions")
table2d_summary(margin.table(UCBAdmissions, 1:2))
#>           Gender
#> Admit      Male Female TOTAL
#>   Admitted 1198    557  1755
#>   Rejected 1493   1278  2771
#>   TOTAL    2691   1835  4526
#> 
#> Number of cases in table: 4526 
#> Number of factors: 2 
#> Test for independence of all factors:
#> 	Chisq = 92.21, df = 1, p-value = 7.814e-22