Session Ready
Exercise

Formula interface in histogram() and xyplot()

Creating simple statistical plots using the lattice package is very similar to doing so using base R graphics. For example, the lattice function histogram() to produce histograms is similar to the base R graphics function hist(); xyplot(), the lattice function to create scatter plots, is similar to the base R graphics function plot().

One important difference is that all lattice functions use a "formula interface" to specify the variables in the plot (just like modeling functions such as lm()). In this approach, the first argument of a function is a "formula", i.e., an expression with a tilde (~) in it. It usually refers to variables in a data frame that is provided as the data argument. This formula interface makes it easy to switch between modeling and plotting the data.

Run the following code.

histogram(~ rate.female, data = USCancerRates)

In the resulting histogram, what is plotted on the x-axis and the y-axis?

Instructions
50 XP
Possible Answers