3
votes

I am producing box plots for two data sets in R + ggplot2 and I'm using facets to print a grid of plots based on two factors. So far so good, the point is that one of the two data sets is completely missing values for one of the levels of one factor, hence I get a grid of 5 x 5 and a grid of 5 x 4, but these grid are meant to be eye-compared, and thus I would like to show the empty plots for the missing values. Is that possible?

Thanks, Tommaso

1
I have a hard to understanding exactly what the problem is, I tried delaying some values in the dioxins example (diamonds$carat[diamonds$cut == 'Very Good'] <- NA) from the facet_grid manual, but the empty category was still displayed. If you culled supply some sample code I would be happy to give it another shot.Eric Fail

1 Answers

6
votes

To quote the documentation at ?facet_grid:

drop: If TRUE, the default, all factor levels not used in the data will automatically be dropped. If FALSE, all factor levels will be shown, regardless of whether or not they appear in the data.

so maybe drop = FALSE?