Session Ready
Exercise

Conditioned scatter plot

For this exercise, you will create a conditioned scatter plot comparing the death rates due to cancer for males and females in the USCancerRates dataset.

Conditioning on state produces too many panels, so in the previous video we saw how to create a new variable that merges states that are in the same division according to the state.division dataset in R. You will use this new variable to condition.

Instructions
100 XP

The USCancerRates dataset has been preloaded, and has an additional field defined named division.

  • Create a division.ordered field by reordering the division field by rate.male plus rate.female.

  • Create a scatter plot with rate.female on the y-axis and rate.male on the x-axis, conditioning on division.ordered.

  • Add an optional argument grid to add a reference grid.

  • Add an optional argument abline to add a reference \(y = x\) diagonal line in each panel. This argument takes a numeric vector of length two, where the first element represents the intercept and the second element represents the slope.