Error in quantile plot

17 views
Skip to first unread message

Art

unread,
Mar 3, 2011, 1:02:12 PM3/3/11
to ggp...@googlegroups.com
Hello all,

I am trying to replicate a plot example (code below with attached image).  However when I run this code I get an Error:

"length(quantiles) == n is not TRUE"

data(Chem97, package = "mlmRev")

#GGplot#

p = ggplot(Chem97)
pg = p + geom_point(aes(sample = gcsescore), stat = "qq",  quantiles = ppoints(100)) + facet_wrap(~score)
print(pg)

Where is the error arising?  And how it is fixed?

Thanks,

 Art
ExamplePlot.png

Dennis Murphy

unread,
Mar 3, 2011, 1:43:00 PM3/3/11
to ggp...@googlegroups.com, Art
Hi:

With a little reading between the lines on the help page, this appears to work:


data(Chem97, package = 'mlmRev')
p <- ggplot(Chem97, aes(sample = gcsescore))
p + stat_qq() + facet_wrap( ~ score) + ylab('gcsescore')

The problem with your code is that you tried to use ppoints(100), but
> table(Chem97$score)

   0    2    4    6    8   10
3688 3627 4619 5739 6668 6681

and that's why you got the error message - your attempt at defining y used a fixed number of ppoints() but there was inequality in the sample sizes in each score subgroup, all of which were not equal to 100. Using geom_point() with my above code doesn't work either because there is no 'y' defined. Since Hadley mentioned on the stat_qq() help page that qplot/ggplot was 'smart' enough to do the right thing, I trusted his word and voila :)

HTH,
Dennis

--
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

Art

unread,
Mar 3, 2011, 2:43:58 PM3/3/11
to ggp...@googlegroups.com, Art
Excellent sleuthing Dennis!  I appreciate the help.

Best,
Art
Reply all
Reply to author
Forward
0 new messages