stat_qq() and grouping variable

127 views
Skip to first unread message

learnr

unread,
Jun 5, 2009, 2:54:08 PM6/5/09
to ggplot2
I am struggling with grouping variables in quantile-quantile plots.

In the example below, shouldn't the result be two separate lines,
rather than two connected lines?

qplot(sample = am, data = mtcars, colour = factor(am), geom = "path",
stat = "qq")

--
http://learnr.wordpress.com/

hadley wickham

unread,
Jun 5, 2009, 3:38:48 PM6/5/09
to learnr, ggplot2
Fixed in devel.
Hadley
--
http://had.co.nz/

learnr

unread,
Jun 6, 2009, 6:00:59 PM6/6/09
to ggplot2
Thanks.

A few additional problems that seem to be specific to stat_qq():

a) facet_wrap doesn't work with stat_qq
qplot(sample = mpg, data = mtcars) + facet_grid( ~ cyl) # works fine
qplot(sample = mpg, data = mtcars) + facet_wrap( ~ cyl) # Error: nrow
* ncol >= n is not TRUE
qplot(wt, am, data = mtcars, colour = factor(am))+ facet_wrap( ~ cyl)
# works fine

b) shorthand functions xlab & labs don't work with stat_qq
p <- qplot(sample = mpg, data = mtcars)
p + xlab("test_xlab") # x axis label not changed
p + labs(x = "test_labs") # x axis label not changed
p + scale_x_continuous("test") #works fine

--
http://learnr.wordpress.com/

hadley wickham

unread,
Jun 8, 2009, 11:18:31 AM6/8/09
to learnr, ggplot2
> a) facet_wrap doesn't work with stat_qq
> qplot(sample = mpg, data = mtcars) + facet_grid( ~ cyl) # works fine
> qplot(sample = mpg, data = mtcars) + facet_wrap( ~ cyl) # Error: nrow
> * ncol >= n is not TRUE
> qplot(wt, am, data = mtcars, colour = factor(am))+ facet_wrap( ~ cyl)
> # works fine

Fixed in devel.

> b) shorthand functions xlab & labs don't work with stat_qq
> p <- qplot(sample = mpg, data = mtcars)
> p + xlab("test_xlab") #  x axis label not changed
> p + labs(x = "test_labs") #  x axis label not changed
> p + scale_x_continuous("test") #works fine

This is a known bug, and I think I know how to fix it, but it requires
quite a bit of work. Hopefully will be done by the end of summer.

Hadley

--
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages