CRAN Status CRAN RStudio mirror downloads Travis-CI Build Status

ggmosaic

ggmosaic was designed to create visualizations of categorical data and is capable of producing bar charts, stacked bar charts, mosaic plots, and double decker plots.

Installation

You can install ggmosaic from github with:

# install.packages("devtools")
devtools::install_github("haleyjeppson/ggmosaic")

Example

library(ggmosaic)
#> Loading required package: ggplot2
ggplot(data = fly) +
  geom_mosaic(aes(x = product(RudeToRecline), fill=DoYouRecline))

geom_mosaic: setting the aesthetics

Aesthetics that can be set:

These values are then sent through productplots functions to create the formula for the desired distribution

Formula: weight ~ fill + x | conds

From the aesthetics to the formula

Example of how the formula is built

These aesthetics set up the formula for the distribution: 1 ~ W + X + Y | Z

Because a mosaic plot is constructed hierarchically through alternating spines, the ordering of the variables is very important.