Given a two dimensions contingency tables, this function outputs HTML code to display, within a dynamic tabbed interface, the count, line row percentages, column percentages and chi-squared residuals tables.

pilltabs(
  tab,
  count = TRUE,
  rows = TRUE,
  cols = TRUE,
  chisq = TRUE,
  resid = TRUE,
  row.names = TRUE
)

Arguments

tab

a two dimensions table object

count

whether or not to display the count table

rows

whether or not to display the row percentages table

cols

whether or not to display the column percentages table

chisq

whether or not to display the table chi-squared test results

resid

whether or not to display the chi-squared residuals table

row.names

whether or not to display the table row names

Value

No value is returned.

Details

The function is intended to be called inside an rmarkdown document.

Examples

data(airquality) tab <- table(airquality$Month, airquality$Ozone > 25) pilltabs(tab)
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> #> --- COUNT --- #> #> | | FALSE| TRUE| #> |:--|-----:|----:| #> |5 | 17| 9| #> |6 | 5| 4| #> |7 | 4| 22| #> |8 | 6| 20| #> |9 | 18| 11| #> #> --- ROWS % --- #> #> | | FALSE| TRUE| Total| n| #> |:---|-----:|----:|-----:|---:| #> |5 | 65.4| 34.6| 100| 26| #> |6 | 55.6| 44.4| 100| 9| #> |7 | 15.4| 84.6| 100| 26| #> |8 | 23.1| 76.9| 100| 26| #> |9 | 62.1| 37.9| 100| 29| #> |All | 43.1| 56.9| 100| 116| #> #> --- COLS % --- #> #> | | FALSE| TRUE| All| #> |:-----|-----:|-----:|-----:| #> |5 | 34| 13.6| 22.4| #> |6 | 10| 6.1| 7.8| #> |7 | 8| 33.3| 22.4| #> |8 | 12| 30.3| 22.4| #> |9 | 36| 16.7| 25.0| #> |Total | 100| 100.0| 100.0| #> |n | 50| 66.0| 116.0| #> #> --- CHI2 RESIDUALS --- #> #> | | FALSE| TRUE| #> |:--|-----:|-----:| #> |5 | 1.73| -1.51| #> |6 | 0.57| -0.50| #> |7 | -2.15| 1.87| #> |8 | -1.56| 1.35| #> |9 | 1.56| -1.35| #> #> #> X-squared = 22.4831, df = 4, p = 0.0001606 #>