A contingency table summarizes counts for combinations of categorical variables. Rows show one distribution, columns show another, and each cell records a frequency. section 9.0 section 9.6.1
A practical R workflow uses the table to:
- Arrange categories such as rest advantage in rows and outcomes such as home wins or losses in columns. section 9.6.1
- Visualize cell frequencies with a balloon plot or mosaic plot. section 9.1 section 9.6.1
- Pass the table to chisq.test() for a chi-square test of independence, then use Cramer's V to quantify association strength. section 9.6.2 section 9.7
NBA rest and home results
Create a 3 × 2 table with rows More Rest, Same Rest, and Less Rest, and columns Home Wins and Home Losses. The resulting counts are 1,552/545, 1,955/1,432, and 717/990. A balloon plot makes larger counts visually prominent; the chi-square test reports a significant relationship, while Cramer's V of about 0.236 indicates a small effect. section 9.6.1 section 9.6.2 section 9.7
chisq_table <- matrix(c(1552, 545, 1955, 1432, 717, 990),
ncol = 2, byrow = TRUE)
rownames(chisq_table) <- c("More Rest", "Same Rest", "Less Rest")
colnames(chisq_table) <- c("Home Wins", "Home Losses")
print(chisq_table)
## Home Wins Home Losses
## More Rest 1552 545
## Same Rest 1955 1432
## Less Rest 717 990
Inspect executable R code that constructs and labels the contingency table. section 9.6.1
