I'm going to use the diamond data set that comes standard with the ggplot2 package to illustrate what I'm looking for.
I want to build a graph that is like this:
library(ggplot2)
ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar(position="dodge")
However, instead of having a count, I would like to return the mean of a continuous variable. I'd like to return cut and color and get the mean carat. If I put in this code:
ggplot(diamonds, aes(carat, fill=cut)) + geom_bar(position="dodge")
My output is a count of the number of carats vs the cut.
Anyone know how to do this?