Home

Awesome

<!-- README.md is generated from README.Rmd. Please edit that file --> <!-- badges: start -->

CRAN
Status CRAN RStudio mirror
downloads R-CMD-check

<!-- badges: end -->

ggmosaic <img src="man/figures/logo.png" align="right" width="120" />

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)
library(dplyr)
happy %>% 
  mutate(finrela = forcats::fct_recode(finrela,
    "far below     " = "far below average",
    "    below" = "below average",
    "average" = "average",
    "above    " = "above average", 
    "l\n   far above" = "far above average")) %>% 
  ggplot() +
  geom_mosaic(aes(x = product(finrela), fill=health), show.legend = FALSE) +
  theme_mosaic() +
  scale_fill_manual(values = c("#4575B4", "#ABD9E9", "#FEE090", "#F46D43"))

<!-- -->

geom_mosaic: setting the aesthetics

In geom_mosaic(), the following aesthetics can be specified:

These values are then sent through repurposed productplots functions to create the desired formula: weight ~ alpha + fill + x | conds.

Version compatibility issues with ggplot2

Since the initial release of ggmosaic, ggplot2 has evolved considerably. And as ggplot2 continues to evolve, ggmosaic must continue to evolve alongside it. Although these changes affect the underlying code and not the general usage of ggmosaic, the general user may need to be aware of compatibility issues that can arise between versions. The table below summarizes the compatibility between versions.

ggmosaicggplot2Axis labelsTick marks
0.3.33.3.3xx
0.3.03.3.0xx
0.2.23.3.0Default labels are okay, but must use <br>scale_*_productlist() to modifyNo tick marks
0.2.23.2.0Default labels okay, but must use <br>scale_*_productlist() to modifyx
0.2.03.2.0Default labels are wrong, but can use <br>labs() to modifyx