gigamonkey/gg — pull request #11 by n8agrin (2012-08-19 20:23:01+00:00)
Title: Grouping

Adds the notion of gg's grouping. This is the most minimal changeset I could come up with that intros the feature without breaking some functionality.

Notes:
* Grouping is a bit of an odd aesthetic but I think of it as taking a data set and splitting it into N number of grouped datasets. This should happen at the layer level. It means that all layer render() methods need to understand how to render an array of arrays.

* Reading the ggplot book it seems that grouping greatly affects the behavior of the stats, so note that my change is probably incorrect in that the grouping happens *after* the stats are computed. However, I couldn't wrap my head around the ggplot stat interaction and wanted to get this minimal viable change out before tackling it.

* Along the way I realized that the SumStatistic implementation is not the same as ggplot's stat_sum. stat_sum seems to do the following. Given a set of data, an x aesthetic and a y aesthetic, calculate the number of points at the same x and y location returning a new data set with duplicate points represented by a point with the same x and y as well as a new variable named 'n' representing the count of points in that location. This is similar to the bin stat, with the exception that the bin stat calculates a density and box width for use in drawing histograms. As far as I can tell there is no Summation statistic in ggplot and the examples I found all suggest using native R methods to sum data before trying to render a plot.