Bug with facet_grid and combining variables in one direction?

10 views
Skip to first unread message

Winston Chang

unread,
Jun 19, 2009, 12:18:00 AM6/19/09
to ggplot2
I tried "adding" two variables in a faceting formula for facet_wrap, and it just threw some errors. I even tried an example directly from the help page for facet_wrap, and that didn't work. Is this a bug?

# These are equivalent, and neither works
qplot(mpg, wt, data=mtcars, facets = vs + am ~ . )
qplot(mpg, wt, data=mtcars) + facet_grid(vs + am ~ . )
#Error in rbind(c("spacer", "strip_h", "spacer"), c("axis_v", "axis_v",  :
#  number of columns of matrices must match (see arg 2)
#In addition: Warning message:
#In rbind(list(1, 1, 1), list(0.450050427161222, 1, 0.524033385806113,  :
#  number of columns of result is not a multiple of vector length (arg 1)


qplot(mpg, wt, data=mtcars, facets = . ~ vs + am )
#Error in cbind("spacer", c("strip_h", "strip_h", "strip_h", "strip_h",  :
#  number of rows of matrices must match (see arg 2)


# This works
qplot(mpg, wt, data=mtcars, facets = vs ~ am)

# facet_wrap seems to work
qplot(mpg, wt, data=mtcars) + facet_wrap( ~ vs+am)


-Winston

hadley wickham

unread,
Jun 22, 2009, 8:57:41 AM6/22/09
to Winston Chang, ggplot2
Hi Winston,

Yes this is a known bug and is on my to do list.

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages