Session Ready
Exercise

Exploring the type option

One of the important graphics parameters that can be set with the par() function is mfrow, which specifies the numbers of rows and columns in an array of plots. Valid values for this parameter are two-element numerical vectors, whose first element specifies the number of rows in the plot array and the second element specifies the number of columns.

A more detailed discussion of using the mfrow parameter is given in Chapter 4 of this course. For now, note that to specify a plot array with three rows and one column, the command would be par(mfrow = c(3, 1)).

The following exercise also introduces the type parameter for the plot() command, which specifies how the plot is drawn. The specific type values used here are:

  • "p" for "points"
  • "l" for "lines"
  • "o" for "overlaid" (i.e., lines overlaid with points)
  • "s" for "steps"
Instructions
100 XP
  • Use the par() function to set the mfrow parameter for a two-by-two plot array.
  • Generate a plot of brain weights from the Animals2 data frame, with observations plotted as points and the title "points" by calling the title() function.
  • Repeat, with observations plotted as lines and the title "lines".
  • Repeat, with observations plotted as overlaid points and lines and the title "overlaid".
  • Repeat, with observations plotted as steps and the title "steps".