## 4.8 Data, aesthetics mappings and layers: Exercise 1

• See the three ggplot2 statements below. Please describe the data, aesthetic mappings and layers used for each of the following plots (Wickham 2016, 14).
• You’ll need to guess a little because you haven’t seen all the datasets and functions yet, but use your common sense! See if you can predict what the plot will look like before running the code.
1. ggplot(mpg, aes(cty, hwy)) + geom_point()
2. ggplot(diamonds, aes(carat, price)) + geom_point()
3. ggplot(economics, aes(date, unemploy)) + geom_line()
4. ggplot(mpg, aes(cty)) + geom_histogram()
• The fact that we can guess the outcome from the code attests to its readability!
• Lesson: Choose readable variable names (e.g., unemploy = bad!)!

### References

Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer.