Session Ready
Exercise

Create a histogram

Histograms are used to show the shape of the distribution of a continuous (numeric) variable. The lattice function to create histograms is histogram(). The two main arguments are a formula, used to specify which variable to plot, and a data frame containing that variable. For example, to plot a histogram of the x column of a data frame, d, you would type the following:

histogram(~ x, data = d)

For this exercise, you will use the built-in dataset airquality, which gives daily measurements of ozone concentration, wind speed, temperature and solar radiation in New York City from May to September of 1973.

Instructions
100 XP
  • Call library() to load the lattice package.

  • Draw a histogram of ozone concentration.

    • Ozone concentration is stored in the Ozone variable.
    • The data argument is the airquality data frame.