| 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/
## 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))
# by cut
d + stat_sum(aes(group=cut))
# by clarity
d + stat_sum(aes(group=clarity))
# Can also weight by another variable
d + stat_sum(aes(group=1, weight = price))
d + stat_sum(aes(group=1, weight = price, size = ..sum..))
# Or using qplot
qplot(cut, clarity, data=diamonds)
qplot(cut, clarity, data=diamonds, stat="sum", group=1)
## End(Not run)