basketball

references:
- ISI, exploration 4.1, p.235

data

basketball <- c(3, 15, 12, 11)
dim(basketball) <- c(2, 2)
dimnames(basketball) <- list(outcome = c("win", "loss"),
                             sell.out = c("yes", "no"))
basketball
##        sell.out
## outcome yes no
##    win    3 12
##    loss  15 11

conditional proportions

addmargins(basketball)     # marginal sums
##        sell.out
## outcome yes no Sum
##    win    3 12  15
##    loss  15 11  26
##    Sum   18 23  41
prop.table(basketball, 2)  # P(outcome | sell.out)
##        sell.out
## outcome       yes        no
##    win  0.1666667 0.5217391
##    loss 0.8333333 0.4782609

mosaicplot

mosaicplot(t(basketball), col = c("orange", "orangered"))