I'm working on a problem where I want to create many plots based on some grouping vars. Some of these groups have many values I want to facet, while others only have a few. I want to display all of the facets to be the same size.
In this reprex, the 8 cyl group only has 2 facets while the others have 3. I want the 2 facets in the 8 cyl group to be the same size as facets in the other group, and the space for the 3rd missing facet to just be blank.
library(tidyverse)
for(i in unique(mtcars$cyl)){
sub_data <- filter(mtcars, cyl == i)
p <- ggplot(sub_data, aes(wt, drat)) +
geom_point() +
facet_wrap(~gear) +
labs(title = paste(i, "cyl"))
print(p)
}