How can I get the same plot without intermediate calculation of the aggregate column.
I have this data:
set.seed(1234) dat <- data.frame(month = gl(3,1,20), family= gl(5,1,20), amount= sample(1:3,20,rep=TRUE))
Using this code, I get a barcode. Where is each bar, this is the sum of the amount for family and for months. I first create a new VG aggegate column.
## I am using data.table , you can get it by ddply also library(data.table) dd <- data.table(dat) hh <- dd[,sum(amount),by=list(month,family)]
Then I use this code:
ggplot(data=hh,aes(x=month,y=V1,fill=family))+ geom_bar(stat = "identity")
To get this plot:

This works, but I want a simpler method. I think, using the stat_sum methods or other ggplot2 methods, I can do this without an intermediate aggregation step. something like that:
#
source share