ggmosaic v0.2.0

0

Monthly downloads

0th

Percentile

Mosaic Plots in the 'ggplot2' Framework

Mosaic plots in the 'ggplot2' framework. Mosaic plot functionality is provided in a single 'ggplot2' layer by calling the geom 'mosaic'.

Readme

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:

  • weight : select a weighting variable
  • x : select variables to add to formula
    • declared as x = product(x1, x2, …)
  • fill : select a variable to be filled
    • if the variable is not also called in x, it will be added to the formula in the first position
  • conds : select a variable to condition on
    • declared as conds = product(cond1, cond2, …)

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

  • weight = 1
  • x = product(Y, X)
  • fill = W
  • conds = product(Z)

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.

Functions in ggmosaic

Name Description
mosaic Template for a mosaic plot. A mosaic plot is composed of spines in alternating directions.
scale_type.tbl_df Helper function for determining scales
product Wrapper for a list
scale_type.product Helper function that ggplot2 needs for determining scales on x and y
geom_mosaic Mosaic plots.
vspine Vertical spine partition: width constant, height varies.
vbar Vertical bar partition: height constant, width varies.
spine Spine partition: divide longest dimension.
scale_type.productlist Helper function for determining scales
squeeze Internal helper function
scale_x_productlist Determining scales for mosaics
ddecker Template for a double decker plot. A double decker plot is composed of a sequence of spines in the same direction, with the final spine in the opposite direction.
hbar Horizontal bar partition: width constant, height varies.
hspine Horizontal spine partition: height constant, width varies.
StatMosaic Geom proto
prodcalc Calculate frequencies.
happy Data related to happiness from the general social survey.
fly Flying Etiquette Survey Data
No Results!

Vignettes of ggmosaic

Name
ggmosaic.Rmd
No Results!

Last month downloads

Details

License GPL (>= 2)
URL http://github.com/haleyjeppson/ggmosaic
BugReports https://github.com/haleyjeppson/ggmosaic
VignetteBuilder knitr
Encoding UTF-8
LazyData true
RoxygenNote 6.1.0
NeedsCompilation no
Packaged 2018-09-12 14:14:51 UTC; haley
Repository CRAN
Date/Publication 2018-09-12 15:00:06 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/ggmosaic)](http://www.rdocumentation.org/packages/ggmosaic)