library(vcd)
# 2-way table of Hair and Eye color
HairEye <- margin.table(HairEyeColor, 2:1)
# Basic usage - observed frequencies as points
mosaic(HairEye,
labeling = labeling_points(scale = 1))
# Show expected frequencies instead of observed
mosaic(HairEye,
labeling = labeling_points(
value_type = "expected",
scale = 2,
seed = 42)
)
# Combine with residual shading
mosaic(HairEye,
shade = TRUE, legend = FALSE,
labeling = labeling_points(scale = 2, seed = 42))
# Make tiles show expected frequencies, show points for observed frequencies
# Reproduces: Fig 6 in Friendly (1995)
mosaic(HairEye,
type = "expected",
shade = TRUE, legend = FALSE,
labeling = labeling_points(scale = 2, seed = 42))
Run the code above in your browser using DataLab