data(Dyestuff, package="lme4")
dotplot(reorder(Batch, Yield) ~ Yield, Dyestuff,
ylab = "Batch", jitter.y = TRUE, pch = 21, aspect = 0.32,
xlab = "Yield of dyestuff (grams of standard color)",
type = c("p", "a"))
I tried to create a similar plot using ggplot2 and got as far as
qplot(reorder(Batch, Yield), Yield, data=Dyestuff,
geom="point", pch=21, xlab=NULL,
ylab="Yield of dyestuff (grams of standard color)") +
stat_summary(fun.y = mean, geom="line") + coord_flip()
but the line I was hoping for didn't materialize. Earlier I had used
position=position_jitter(w=0.1,h=0) in the call to qplot() but I
pulled it in case the jittered values were considered the x values
when grouping the y's. However, even without the jittering I seem to
be unable to add the line, perhaps because one scale is a factor.
Suggestions welcome.
I think you are correct about the need for a continuous x scale:
qplot(x = reorder(Batch, Yield), y = Yield, data=Dyestuff,
geom="point", pch=21, xlab=NULL,
ylab="Yield of dyestuff (grams of standard color)") +
stat_summary( aes( x = as.numeric( reorder(Batch, Yield) ) ), fun.y =
mean, geom="line") +
coord_flip()
Hope this helps,
fernando
-----Mensaje original-----
De: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com] En nombre de
Douglas Bates
Enviado el: jueves, 27 de enero de 2011 21:39
Para: ggplot2
Asunto: use of stat_summary with a factor
Suggestions welcome.
--
You received this message because you are subscribed to the ggplot2 mailing
list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
On Thu, Jan 27, 2011 at 2:52 PM, Ista Zahn <iz...@psych.rochester.edu> wrote:
> Hi,
> Use group=1:
>
> stat_summary(fun.y = mean, geom="line", aes(group=1))
>
> Best,
> Ista
>> --
>> You received this message because you are subscribed to the ggplot2 mailing list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+u...@googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
>>
>
>
>
> --
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
>
stat_summary(fun.y = mean, geom="line", aes(group=1))
Best,
Ista
On Thu, Jan 27, 2011 at 3:39 PM, Douglas Bates <ba...@stat.wisc.edu> wrote: