I am using facet_grid in package "ggplot2" to facet columns by two variables. Each facet gets two header stips - one for each conditioning variable. Each value of the first variable is repeated for all levels of the second variable. I would like to know if I could have a single header for the first variable spread across all levels of the second variable.
Here is a toy example:
dat <- expand.grid(x=c(0,1), A=c("a1","a2"), B=c("b1","b2","b3"))
dat$y <- rnorm(nrow(dat))
ggplot(dat, aes(x, y)) + geom_point() + facet_grid(~A+B)
Each level of A is repeated in 3 consecutive headers - one for each level of B. I would like to have just two header strips for A - one covering the first 3 panels, and another for the second 3 panels.
Does anyone know if/how this can be done?