8 Exercises

8.1 Working Backwards

These exercises require the materials from chapters 1-5.

Reproduce these plots with the specified datasets.

  1. Use mtcars.

  2. Use mtcars.

  3. Use airquality.

  4. Use airquality.

8.2 The Plotting Workflow

These exercises require the materials from chapters 1-7.

Pick either one of these datasets from ggplot2:

  • midwest, data on Midwest counties from the 2000 Census
  • diamonds, attributes of diamonds

Use this dataset for the following exercises:

  1. Create a plot of…

    1. counts by a discrete variable.

    2. a histogram or density of a continuous variable.

    3. a summary statistic (mean, median, minimum, maximum, etc.) of a continuous variable for each value of a discrete variable.

    4. a scatterplot of two continuous variables, with a smoothed conditional mean line.

    5. three variables.

  2. Using one of the plots you created for exercise 1, …

    1. change the title and axis labels.

    2. change the theme, either manually or with a preset.

    3. save it as an image file.