stat_sum {ggplot2} | R Documentation |
Sum unique values. Useful for overplotting on scatterplots
stat_sum(mapping=NULL, data=NULL, geom="point", position="identity", ...)
mapping |
mapping between variables and aesthetics generated by aes |
data |
dataset used in this layer, if not specified uses plot dataset |
geom |
geometric used by this layer |
position |
position adjustment used by this layer |
... |
ignored |
This page describes stat_sum, see layer
and qplot
for how to create a complete plot from individual components.
A layer
The following aesthetics can be used with stat_sum. Aesthetics are mapped to variables in the data with the aes
function: stat\_sum(\code{aes}(x = var))
x
: x position (required)
y
: y position (required)
size
: size
Hadley Wickham, http://had.co.nz/
ggfluctuation
: Fluctuation diagram, which is very similar
## Not run: d <- ggplot(diamonds, aes(x = cut, y = clarity)) # Need to control which group proportion calculated over # Overall proportion d + stat_sum(aes(group = 1)) d + stat_sum(aes(group = 1)) + scale_size(to = c(3, 10)) d + stat_sum(aes(group = 1)) + scale_area(to = c(3, 10)) # by cut d + stat_sum(aes(group = cut)) d + stat_sum(aes(group = clarity, colour = cut)) # by clarity d + stat_sum(aes(group = clarity)) d + stat_sum(aes(group = clarity, colour = clarity)) # Instead of proportions, can also use sums d + stat_sum(aes(size = ..n..)) # Can also weight by another variable d + stat_sum(aes(group = 1, weight = price)) d + stat_sum(aes(group = 1, weight = price, size = ..n..)) # Or using qplot qplot(cut, clarity, data = diamonds) qplot(cut, clarity, data = diamonds, stat = "sum", group = 1) ## End(Not run)