rp.contingency: Visualisation of two-way contingency tables with...

View source: R/rp_contingency.R

rp.contingencyR Documentation

Visualisation of two-way contingency tables with uncertainties

Description

A two-way contingency table is displayed graphically and the uncertainties associated with a chi-squared test may be visualised.

Usage

rp.contingency(x, uncertainty = 'none', proportion.scale = 'fixed', cols)

Arguments

x

a two-way table or matrix of observed counts.

uncertainty

a character value which controls whether uncertainties are displayed for each cell, in 'shading' or 'violin' style.

proportion.scale

a character value specifying whether the proportion scale is 'fixed' or 'free'.

cols

a named vector of characters specifying colours to be used in the plot. See help(rp.colours) for details.

Details

The table is displayed in a form which stratifies by columns. If it more appropriate to stratify by the rows of x then the function may be applied to t(x).

The uncertainties associated with each cell are based on the standard errors associated with standardised residuals. See the help file for chisq.test for details.

Missing data are not allowed.

Examples

## Not run: 
   x <- matrix(c(19, 41, 32, 28), ncol = 2,
            dimnames = list(c("non-smoker", "smoker"),
                            c("cases", "controls")))
   rp.contingency(x)
   rp.contingency(x, style = "aligned")
   rp.contingency(x, uncertainty = TRUE)
   rp.contingency(x, uncertainty = TRUE) + ggplot2::coord_flip()

## End(Not run)

rpanel documentation built on March 12, 2026, 9:07 a.m.