r - apply function to group values while plotting (ggplot) -
just wondering if possible manipulable y-axis of ggplot geom_bar
for example:
library(plyr) df1 <- data.frame(a=c(5,5,10,10,10)) df2 <- ddply(df1,.(a),sum) ggplot(df2,aes(a,v1)) + geom_bar(stat="identity")
instead of aggregating df1, possible produce plot straight in ggplot?
you can using stat_summary
:
ggplot(df1, aes(a, a)) + stat_summary(fun.y=sum, geom="bar")
r ggplot2
No comments:
Post a Comment