Session Ready
Exercise

Creating a triangular array of plots

The previous exercise asked you to create a plot array using the layout() function. Recall the layout matrix from the previous exercise:

> layoutMatrix
     [,1] [,2]
[1,]    0    1
[2,]    2    0
[3,]    0    3

This exercise asks you to use this array to give three different views of the whiteside data frame.

The first plot, on the upper right of the plot array, shows the relationship of Gas and Temp using all data from whiteside. The second plot, in the center left of the plot array, shows the relationship of the two variables using data where Insul is equal to "Before". Finally, the third plot, on the lower right of the plot array, shows the relationship using data where Insul is equal to "After".

The primary motivation for this exercise is that it is not possible to construct a plot array in this format using the mfrow parameter, since the array is not rectangular.

Instructions
100 XP

The layout matrix you set up in the previous is available in your workspace as layoutMatrix. The whiteside data frame is already available in your workspace as well.

  • Call the layout() function on layoutMatrix to set up the plot array.
  • Construct a vector indexB that points to only those records with the Insul value "Before" and a vector indexA that points to only those records with the Insul value "After".
  • Plot the Gas versus Temp values from the indexB data in the upper right plot in your array, using the y-axis limits c(0, 8). Give this plot the title "Before data only".
  • Plot the Gas versus Temp values from the complete dataset in the center left plot, using the same y-axis limits as the first plot. Give this plot the title "Complete dataset".
  • Plot the Gas versus Temp values from the indexA data in the lower right plot, again using the same y-axis limits. Give this plot the title "After data only".