R - draw mosaic plots with mosaic() from vcd package

30 May 2020

http://www.sthda.com/english/articles/32-r-graphics-essentials/129-visualizing-multivariate-categorical-data/#mosaic-plot

A mosaic plot is basically an area-proportional visualization of observed frequencies, composed of tiles (corresponding to the cells) created by recursive vertical and horizontal splits of a rectangle. The area of each tile is proportional to the corresponding cell entry, given the dimensions of previous splits.

Read more about vcd package and Visualizing Multi-way Contingency Tables:

https://cran.r-project.org/web/packages/vcd/vignettes/strucplot.pdf

library(vcd)
mosaic(HairEyeColor, shade = TRUE, legend = TRUE) 
[ R  function  visualization  plot  package  ]