I have a data frame containing three factors (Scenarios, Emission Target, and Climate Action Year) against which there are several numeric-valued metrics.
What I am looking for is to create a box plot for a given metric analyzed over the "Scenarios" factor and plotted as a function of "Climate Action Year" factor, faceted as a grid by the factor "Emission Target".
Here is what I tried:
a1 <- ggplot(ResDF, aes(ResDF$CAY, ResDF$IncrCost)) + geom_boxplot() + coord_flip() + facet_grid(~ResDF$EmRedTgt, scale="free") + theme_minimal()
b1 <- ggplot(ResDF, aes(ResDF$CAY, ResDF$Etot)) + geom_boxplot() + coord_flip() + facet_grid(~ResDF$EmRedTgt, scale="free") + theme_minimal()
p <- grid.arrange(a1,b1)
Instead of there being 36 box plots, one for each for each climate action year between 2015 and 2050 for each of the emission targets, I see 9 box plots each for each emission target (see attached figure). The data frame I am using can be found here (data frame csv file).
As a novice to R, I think I'm missing something obvious here. It also makes me wonder what dimension the box plot stat is analyzing. Any directions would be most helpful!