Session Ready
Exercise

Modifying strip labels

Instead of being automatically plotted, the result of a lattice call can be saved in a variable, for further manipulation before being plotted. One useful feature of such objects is that they can be viewed as matrices or arrays, with dimensions defined by conditioning variables. In particular, their dimnames() are used as strip labels.

tplot <-
    densityplot(~ rate.male + rate.female | division.ordered, 
                data = USCancerRates, outer = TRUE, 
                plot.points = FALSE, as.table = TRUE)
dimnames(tplot)[[2]]
# [1] "rate.male" "rate.female"

Your objective in this exercise is to use this feature to specify custom labels, as an alternative to the strip argument used earlier for the same purpose.

Instructions
100 XP

The USCancerRates dataset is already pre-loaded.

  • Change the dimnames() of the tplot object so that the names for the second dimension become "Male" and "Female".
  • Update the object by changing the default x-axis label to "Rate" before plotting it.