Session Ready
Exercise

Using the mosaicplot() function

A mosaic plot may be viewed as a scatterplot between categorical variables and it is supported in R with the mosaicplot() function.

As this example shows, in addition to categorical variables, this plot can also be useful in understanding the relationship between numerical variables, either integer- or real-valued, that take only a few distinct values.

More specifically, this exercise asks you to construct a mosaic plot showing the relationship between the numerical carb and cyl variables from the mtcars data frame, variables that exhibit 6 and 3 unique values, respectively.

Instructions
100 XP

Apply the mosaicplot() function with the formula interface to see how the levels of the carb variable vary with the levels of the cyl variable from the mtcars data frame.