I am working my way through R4DS, and am trying to tweak my solution for 3.8.1 exercise 4. I ended up with the following code:
ggplot(data = mpg, mapping = aes(x = manufacturer, y = hwy/cty, colour = year)) +
geom_boxplot() + coord_flip()
This does not work as intended. But when I replace colour = year
with colour = drv
, I get a nice grouped boxplot. Why can’t this be done with year
?
RStudio 0.99.902; ggplot2 v. 2.1.0.