Package ggmosaic. February 9, 2017

Similar documents
Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package ggseas. June 12, 2018

Package ggrepel. September 30, 2017

Package lvplot. August 29, 2016

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package docxtools. July 6, 2018

Package ggsubplot. February 15, 2013

Package statar. July 6, 2017

Package ggqc. R topics documented: January 30, Type Package Title Quality Control Charts for 'ggplot' Version Author Kenith Grey

Package fastdummies. January 8, 2018

Package vinereg. August 10, 2018

Package knitrprogressbar

Package robotstxt. November 12, 2017

Package interplot. R topics documented: June 30, 2018

Package bisect. April 16, 2018

Package canvasxpress

Package ECctmc. May 1, 2018

Package fastqcr. April 11, 2017

Package splithalf. March 17, 2018

Package datasets.load

Package ggspectra. May 7, 2018

Package reval. May 26, 2015

Package catenary. May 4, 2018

Package barcoder. October 26, 2018

Package gtrendsr. October 19, 2017

Package gtrendsr. August 4, 2018

Package vip. June 15, 2018

Package rgho. R topics documented: January 18, 2017

Package jpmesh. December 4, 2017

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package rsppfp. November 20, 2018

Package ggpmisc. May 4, 2018

Package qualmap. R topics documented: September 12, Type Package

Package WordR. September 7, 2017

Package facerec. May 14, 2018

Package quickreg. R topics documented:

Package plotluck. November 13, 2016

Package preprosim. July 26, 2016

Package climber. R topics documented:

Package opencage. January 16, 2018

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package readxl. April 18, 2017

Package editdata. October 7, 2017

Package postal. July 27, 2018

Package QCAtools. January 3, 2017

Package qicharts2. March 3, 2018

Package githubinstall

Package profvis. R topics documented:

Package oec. R topics documented: May 11, Type Package

Package messaging. May 27, 2018

Package ezsummary. August 29, 2016

Package jrt. January 4, 2019

Package postgistools

Package censusapi. August 19, 2018

Package TrafficBDE. March 1, 2018

Package validara. October 19, 2017

Package omu. August 2, 2018

Package d3heatmap. February 1, 2018

Package ASICS. January 23, 2018

Package wrswor. R topics documented: February 2, Type Package

Package NFP. November 21, 2016

Package clipr. June 23, 2018

Package packcircles. April 28, 2018

Package kdtools. April 26, 2018

Package RmarineHeatWaves

Package dynsim. R topics documented: August 29, 2016

Package widyr. August 14, 2017

Package bigqueryr. October 23, 2017

Package autocogs. September 22, Title Automatic Cognostic Summaries Version 0.1.1

Package benchmarkme. R topics documented: February 26, Type Package Title Crowd Sourced System Benchmarks Version 0.2.

Package ggloop. October 20, 2016

Package labelled. December 19, 2017

Package mdftracks. February 6, 2017

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package SEMrushR. November 3, 2018

Package calpassapi. August 25, 2018

Package samplesizecmh

Package nngeo. September 29, 2018

Package dkanr. July 12, 2018

Package reghelper. April 8, 2017

Package sigmanet. April 23, 2018

Package tidyselect. October 11, 2018

Package shinyfeedback

Package fitbitscraper

Package arphit. March 28, 2019

Package lumberjack. R topics documented: July 20, 2018

Package OLScurve. August 29, 2016

Package ezknitr. September 16, 2016

Package modmarg. R topics documented:

Package balance. October 12, 2018

Package sfc. August 29, 2016

Package queuecomputer

Package d3r. January 29, 2019

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package RODBCext. July 31, 2017

Package kerasformula

Package datapasta. January 24, 2018

Package embed. November 19, 2018

Transcription:

Title Mosaic Plots in the 'ggplot2' Framework Version 0.1.2 Package ggmosaic February 9, 2017 Mosaic plots in the 'ggplot2' framework. Mosaic plot functionality is provided in a single 'ggplot2' layer by calling the geom 'mosaic'. Depends R (>= 3.2.0), ggplot2 (>= 2.2.0), productplots (>= 0.1.1) Imports plotly (>= 4.5.5), dplyr, purrr, tidyr, gridextra, NHANES License GPL (>= 2) URL http://github.com/haleyjeppson/ggmosaic BugReports https://github.com/haleyjeppson/ggmosaic LazyData TRUE RoxygenNote 5.0.1.9000 Suggests knitr, rmarkdown VignetteBuilder knitr NeedsCompilation no Author Haley Jeppson [aut, cre], Heike Hofmann [aut], Di Cook [aut], Hadley Wickham [ctb] Maintainer Haley Jeppson <hjeppson@iastate.edu> Repository CRAN Date/Publication 2017-02-09 00:47:04 R topics documented: ddecker........................................... 2 geom_mosaic........................................ 2 hspine............................................ 5 mosaic............................................ 6 product........................................... 6 scale_productlist...................................... 7 1

2 geom_mosaic scale_type.product..................................... 8 scale_type.productlist.................................... 9 spine............................................. 9 StatMosaic......................................... 9 vspine............................................ 10 Index 11 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. 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. ddecker(direction = "h") direction direction of first split geom_mosaic Mosaic plots. A mosaic plot is a convenient graphical summary of the conditional ditributions in a contingency table and is composed of spines in alternating directions. geom_mosaic(mapping = NULL, data = NULL, stat = "mosaic", position = "identity", na.rm = FALSE, divider = mosaic(), offset = 0.01, show.legend = NA, inherit.aes = TRUE,...) stat_mosaic(mapping = NULL, data = NULL, geom = "mosaic", position = "identity", na.rm = TRUE, divider = mosaic(), show.legend = NA, inherit.aes = TRUE, offset = 0.01,...)

geom_mosaic 3 mapping data stat position na.rm divider offset show.legend inherit.aes Set of aesthetic mappings created by aes or aes_. If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. The data to be displayed in this layer. There are three options: If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot. A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify for which variables will be created. A function will be called with a single argument, the plot data. The return value must be a data.frame., and will be used as the layer data. The statistical transformation to use on the data for this layer, as a string. Position adjustment, either as a string, or the result of a call to a position adjustment function. If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values. Divider function. The default divider function is mosaic() which will use spines in alternating directions. The four options for partioning: vspine Vertical spine partition: width constant, height varies. hspine Horizontal spine partition: height constant, width varies. vbar Vertical bar partition: height constant, width varies. hbar Horizontal bar partition: width constant, height varies. Set the space between the first spine logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn t inherit behaviour from the default plot specification, e.g. borders.... other arguments passed on to layer. These are often aesthetics, used to set an aesthetic to a fixed value, like color = 'red' or size = 3. They may also be parameters to the paired geom/stat. geom The geometric object to use display the data Computed variables xmin location of bottom left corner xmax location of bottom right corner ymin location of top left corner ymax location of top right corner

4 geom_mosaic Examples data(titanic) titanic <- as.data.frame(titanic) titanic$survived <- factor(titanic$survived, levels=c("yes", "No")) ggplot(data=titanic) + geom_mosaic(aes(weight=freq, x=product(class), fill=survived)) # good practice: use the 'dependent' variable (or most important variable) # as fill variable ggplot(data=titanic) + geom_mosaic(aes(weight=freq, x=product(class, Age), fill=survived)) # we can change where we define variables ggplot(data=titanic, aes(weight = Freq, fill=survived, x=product(class, Age))) + geom_mosaic() ggplot(data=titanic) + geom_mosaic(aes(weight=freq, x=product(class), conds=product(age), fill=survived)) ggplot(data=titanic) + geom_mosaic(aes(weight=freq, x=product(survived, Class), fill=age)) ## Not run: data(happy, package="productplots") geom_mosaic(aes(x=product(happy)), divider="hbar") geom_mosaic(aes(x=product(happy))) + coord_flip() # weighting is important geom_mosaic(aes(weight=wtssall, x=product(happy))) geom_mosaic(aes(weight=wtssall, x=product(health), fill=happy)) + theme(axis.text.x=element_text(angle=35)) geom_mosaic(aes(weight=wtssall, x=product(health), fill=happy), na.rm=true) geom_mosaic(aes(weight=wtssall, x=product(health, sex, degree), fill=happy), na.rm=true) # here is where a bit more control over the spacing of the bars is helpful: # set labels manually: geom_mosaic(aes(weight=wtssall, x=product(age), fill=happy), na.rm=true, offset=0) + scale_x_productlist("age", labels=c(17+1:72)) # thin out labels manually: labels <- c(17+1:72) labels[labels %% 5!= 0] <- "" geom_mosaic(aes(weight=wtssall, x=product(age), fill=happy), na.rm=true, offset=0) + scale_x_productlist("age", labels=labels)

hspine 5 geom_mosaic(aes(weight=wtssall, x=product(age), fill=happy, conds = sex), divider=mosaic("v"), na.rm=true, offset=0.001) + scale_x_productlist("age", labels=labels) # facetting works!!!! geom_mosaic(aes(weight=wtssall, x=product(age), fill=happy), na.rm=true, offset = 0) + facet_grid(sex~.) + scale_x_productlist("age", labels=labels) geom_mosaic(aes(weight = wtssall, x = product(happy, finrela, health)), divider=mosaic("h")) geom_mosaic(aes(weight = wtssall, x = product(happy, finrela, health)), offset=.005) # Spine example geom_mosaic(aes(weight = wtssall, x = product(health), fill = health)) + facet_grid(happy~.) ## End(Not run) hspine Horizontal spine partition: height constant, width varies. Horizontal spine partition: height constant, width varies. hspine(data, bounds, offset = offset, max = NULL) data bounds offset max bounds data frame bounds of space to partition space between spines maximum value

6 product mosaic Template for a mosaic plot. A mosaic plot is composed of spines in alternating directions. Template for a mosaic plot. A mosaic plot is composed of spines in alternating directions. mosaic(direction = "h") direction direction of first split product Wrapper for a list Wrapper for a list product(x,...) x name of the variable going into the product plot.... arbitrarily many additional variables. Examples data(titanic) titanic <- as.data.frame(titanic) titanic$survived <- factor(titanic$survived, levels=c("yes", "No")) ggplot(data=titanic) + geom_mosaic(aes(weight=freq, x=product(survived, Class), fill=survived))

scale_productlist 7 scale_productlist Product scales for mosaic plots product scales are especially introduced for use with mosaic plots: they are a hybrid of continuous and discrete scales. scale_x_productlist(name = waiver(), breaks = product_breaks(), minor_breaks = NULL, labels = product_labels(), limits = NULL, expand = waiver(), oob = scales:::censor, na.value = NA_real_, trans = "identity", position = "bottom", sec.axis = waiver()) ScaleContinuousProduct name breaks minor_breaks labels limits expand The name of the scale. Used as axis or legend title. If NULL, the default, the name of the scale is taken from the first mapping used for that aesthetic. One of: NULL for no breaks waiver() for the default breaks computed by the transformation object A numeric vector of positions A function that takes the limits as input and returns breaks as output One of: NULL for no minor breaks waiver() for the default breaks (one minor break between each major break) A numeric vector of positions A function that given the limits returns a vector of minor breaks. One of: NULL for no labels waiver() for the default labels computed by the transformation object A character vector giving labels (must be same length as breaks) A function that takes the breaks as input and returns labels as output A numeric vector of length two providing limits of the scale. Use NA to refer to the existing minimum or maximum. A numeric vector of length two giving multiplicative and additive expansion constants. These constants ensure that the data is placed some distance away from the axes. The defaults are c(0.05, 0) for continuous variables, and c(0, 0.6) for discrete variables.

8 scale_type.product oob na.value trans position sec.axis Function that handles limits outside of the scale limits (out of bounds). The default replaces out of bounds values with NA. Missing values will be replaced with this value. Either the name of a transformation object, or the object itself. Built-in transformations include "asn", "atanh", "boxcox", "exp", "identity", "log", "log10", "log1p", "log2", "logit", "probability", "probit", "reciprocal", "reverse" and "sqrt". A transformation object bundles together a transform, it s inverse, and methods for generating breaks and labels. Transformation objects are defined in the scales package, and are called name_trans, e.g. boxcox_trans. You can create your own transformation with trans_new. The position of the axis. "left" or "right" for vertical scales, "top" or "bottom" for horizontal scales specify a secondary axis Format An object of class ScaleContinuousProduct (inherits from ScaleContinuousPosition, ScaleContinuous, Scale, ggproto) of length 4. scale_type.product Helper function that ggplot2 needs for determining scales on x and y Helper function that ggplot2 needs for determining scales on x and y scale_type.product(x) x variable under consideration Value character string "product"

scale_type.productlist 9 scale_type.productlist Helper function that ggplot2 needs for determining scales on x and y Helper function that ggplot2 needs for determining scales on x and y scale_type.productlist(x) x variable under consideration Value character string "productlist" spine Spine partition: divide longest dimesion. Spine partition: divide longest dimesion. spine(data, bounds, offset = offset, max = NULL) data bounds offset max bounds data frame bounds of space to partition space between spines maximum value StatMosaic Geom proto Geom proto

10 vspine vspine Vertical spine partition: width constant, height varies. Vertical spine partition: width constant, height varies. vspine(data, bounds, offset = offset, max = NULL) data bounds offset max bounds data frame bounds of space to partition space between spines maximum value

Index Topic datasets scale_productlist, 7 StatMosaic, 9 aes, 3 aes_, 3 borders, 3 boxcox_trans, 8 ddecker, 2 fortify, 3 geom_mosaic, 2 ggplot, 3 hspine, 5 mosaic, 6 product, 6 scale_productlist, 7 scale_type.product, 8 scale_type.productlist, 9 scale_x_productlist (scale_productlist), 7 ScaleContinuousProduct (scale_productlist), 7 spine, 9 stat_mosaic (geom_mosaic), 2 StatMosaic, 9 trans_new, 8 vspine, 10 11