Session Ready
Exercise

Creating arrays with different sized plots

Besides creating non-rectangular arrays, the layout() function can be used to create plot arrays with different sized component plots -- something else that is not possible by setting the par() function's mfrow parameter.

This exercise illustrates the point, asking you to create a standard scatterplot of the zn versus rad variables from the Boston data frame as a smaller plot in the upper left, with a larger sunflower plot of the same data in the lower right.

Instructions
100 XP

The Boston data frame in the MASS package is already available in your workspace.

  • Using the c() function:
  • Create the three-element vector row1 with values (1, 0, 0).
  • Create the three-element vector row2 with values (0, 2, 2).
  • Combine the first vector with two copies of the second vector into layoutVector, a vector of length 9.
  • Using the matrix() function, convert layoutVector into the 3-by-3 matrix layoutMatrix whose first row is row1 and whose second and third rows are row2.
  • Use the layout() function with layoutMatrix to configure a two-element plot array.
  • In the first (smaller) plot, create a standard scatterplot of the zn variable versus the rad variable from the Boston data frame.
  • In the second (larger) plot, create a sunflower plot using the sunflowerplot() function and the same variables.