The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

mosaicresid

A ggplot2-native alternative to base R’s mosaicplot(shade = TRUE).

library(mosaicresid)
library(ggplot2)

ggplot(Titanic) +
  geom_mosaic_resid(aes(x = Class, y = Survived)) +
  theme_minimal()

geom_mosaic_resid() takes two categorical variables mapped the usual ggplot2 way, aes(x =, y =), and automatically:

Works on raw, one-row-per-observation data or already-aggregated contingency-table data through the same code path, and the underlying tile geometry and residuals are available directly as a tidy data frame via compute_mosaic_residuals().

Installation

# development version from GitHub
# install.packages("remotes")
remotes::install_github("sbutler22/geom_mosaic")

Documentation

License

MIT

Use of AI

This package was developed with substantial help from Claude (Anthropic), used as a coding assistant. Claude drafted much of the R code, roxygen documentation, tests, and vignette text, and helped debug issues such as compatibility with ggplot2 4.0. I directed the design (including the aes(x =, y =) interface, the two-variable scope, and the default color scale), reviewed and tested the code, chose the example datasets, and edited the documentation. The residual calculations are checked against base R’s own mosaicplot() formulas in the package’s test suite.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.