7.2 Data on the sinking of the Titanic
7.3 What is a mosaicplot?
7.4 Different mosaicplots for different questions of interest
Data on the sinking of the Titanic | 132
doubledecker(Survived ~ Sex, data = Titanic, gp = gpar(fill = c("grey90", "red"))) doubledecker(Survived ~ Class, data = Titanic, gp = gpar(fill = c("grey90", "red")))
133
doubledecker(Survived ~ Sex + Class, data = Titanic, gp = gpar(fill = c("grey90", "red")))
What is a mosaicplot? | 135
data(Alligator, package="vcdExtra") Alg1
136
pairs(xtabs(count ~ ., Alligator))
137
doubledecker(xtabs(count ~ lake + sex, data = Alligator), gp = gpar(fill = c("grey90", "steelblue"))) doubledecker(xtabs(count ~ food + size, data = Alligator), gp = gpar(fill = c("grey90", "tomato")))
138
Alg2
139
ggplot(Alg1, aes(food, count, fill=sex)) + geom_bar(stat = "identity") + facet_grid(lake ~ sex + size) + theme(legend.position="none")
Different mosaicplots for different questions of interest | 141
data(Zoo, package="seriation") fluctile(table(select(Zoo, c(hair, eggs:backbone))), label=FALSE)
142
data(Arthritis) Arthritis
143
Allig3
145
data(housing, package="MASS") mosaic(xtabs(Freq ~ Cont + Type + Infl + Sat, data = housing), direction = c("h", "v", "v", "h"), gp = gpar(fill = c("grey", "grey","red")), spacing = spacing_highlighting)
rmb(formula = ~Type+Cont+Infl+Sat, data = housing, cat.ord = 3, spine = TRUE, freq.trans = "const")
147
data(housing, package="MASS") rmb(formula = ~Type+Infl+Cont+Sat, data = housing, col.vars = c(FALSE,TRUE,TRUE,FALSE), label.opt = list(abbrev = 3, yaxis=FALSE))
rmb(formula = ~Type+Infl+Cont+Sat, data = housing, eqwidth=TRUE, col.vars = c(FALSE,TRUE,TRUE,FALSE), label.opt = list(abbrev = 3, yaxis=FALSE))