Session Ready
Exercise

Create a scatterplot

Scatter plots show the relationship between two continuous (numeric) variables by plotting each data point as a symbol in the x-y coordinate plane. They are created using the lattice function xyplot(). As with histogram(), the two main arguments are a formula specifying which two variables to plot and a data frame. For example, to plot the x and y columns of a data frame d, you would type the following.

xyplot(y ~ x, data = d) 
Instructions
100 XP
  • Call library() to load the lattice package.

  • Draw a scatter plot of ozone concentration on the y-axis against solar radiation on the x-axis.

    • Ozone concentration is stored in the Ozone variable.
    • Solar radiation is stored in the Solar.R variable.
    • These variables are columns in the airquality data frame.