thomas
unread,Aug 3, 2010, 4:33:12 AM8/3/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
Hi,
I looked for a while without success :(
Is it possible to bin values on the horizontal axis when using
stat_summary… This would allow much greater flexibility when
summarizing data will small jittering in x. I wondered if it would be
possible to use stat_bin but I doubt it is possible to call two stats
simultaneously. I'm probably missing something obvious…
Here is some small example to illustrate this point:
library(ggplot2)
d <- data.frame(a = rep(c(1,3,5), 10),
b = rnorm(30),
c = rep(1:10, each=3))
# works fine if points are aligned
qplot(a, b, data=d, color=factor(c), geom=c("point", "path")) +
stat_summary(fun.data="mean_cl_normal", geom = "errorbar", width=0.5,
colour="black")
# if the data are jittered (even tinily), no more summary can be
computed without binning
d$a2 <- jitter(d$a, 0.1)
qplot(a2, b, data=d, color=factor(c), geom=c("point", "path")) +
stat_summary(fun.data="mean_cl_normal", geom = "errorbar", width=0.5,
colour="black")
Thanks for your help,
Thomas