2.9 Exercises
What’s the problem with the plot created by
ggplot(mpg, aes(cty, hwy)) + geom_point()? Which of the geoms that we learned is most effective at remedying the problem?One challenge with
ggplot(mpg, aes(class, hwy)) + geom_boxplot()is that the ordering of class is alphabetical, which is not terribly useful. How could you change thefactor levelsto be more informative?Rather than reordering the
factor by hand, you can do it automatically based on the data:ggplot(mpg, aes(reorder(class, hwy), hwy)) + geom_boxplot(). What does reorder() do? Read the documentation.