Skip to content

Mosaicplots in the ggplot2 framework: ggmosaic

Heike Hofmann edited this page Mar 1, 2016 · 25 revisions

** Background

Explain the motivation for your coding project. What problem would it solve?

** Related work

Mosaic plots have been implemented in a variety of packages: mosaicplot() is one of the base graphics in the stats package, mosaic() is part of the vcd package. Also part of the vcd package is strucplot(), providing an extension to mosaic(). qmosaic() is an interactive implementation of mosaic plots as part of the cranvas package, and the productplots package is an implementation based on the ggplot2 framework. Why do we need another implementation? I don't want to downtalk any of the existing solutions, but there are some unresolved issues in all of them, e.g.

  • default spacing and labels are not quite right in the mosaicplot() implementation. From a data visualization point of view, it makes sense to make the best use of the space available, and the (default) spacing choices are not doing that.
  • In the vcd implementation, there are some unintuitive ways, the formula gets resolved, e.g. mosaic(Improved ~ Treatment | Sex, data = Arthritis, zero_size = 0, highlighting_direction = "right") gives the same result as mosaic(Improved ~ Treatment + Sex, data = Arthritis, zero_size = 0, highlighting_direction = "right"). Statistically, not the same things are shown, and the chart should reflect that.
  • the qmosaic implementation in cranvas allows very powerful interactions with the chart, but the dependency on Qt makes cranvas very hard to install (besides a specific version of Qt with tricky paths, it also needs both the qtbase and the qtpaint package to work)
  • the implementation of the productplots package comes the closest to the envisioned result of this project. However, prodplot is functionality on top of the ggplot2 package and not integrated with it as a geom, which makes it impossible to use additional ggplot2 tools such as facetting and layering except in very special cases.

** Details of your coding project

What exactly do you want your student to code in the 3-month deadline? What functions? What do they do? Docs? Tests? Vignettes?

** Expected impact

Mentors, please explain how this project will produce a useful package for the R community.

** Mentors

Once you have a solution to the medium or/and the hard problem, please get in touch with [[https://github.com/heike][Heike Hofmann]] hofmann@iastate.edu and/or [[https://github.com/dicook][Dianne Cook]].

** Tests

Several tests that potential students can do to demonstrate their capabilities for this particular project. Please modify the suggestions below to make them specific for your project.

  • Easy: Install the [[https://github.com/hadley/productplots][productplots package]] from github (you might have to install the devtools package first). Run one of the examples, put the chart in a knitr/Rmarkdown document and write a paragraph to explain the chart.
  • Medium: something a bit more complicated. You can encourage students to write a script or some functions that show their R coding abilities.
  • Hard: Can the student write a package with Rd files, tests, and vigettes? If your package interfaces with non-R code, can the student write in that other language?

** Solutions of tests

Students, please post a link to your test results here.

Clone this wiki locally