Session Ready
Exercise

Plotting correlation matrices with the corrplot() function

Correlation matrices were introduced in the video as a useful tool for obtaining a preliminary view of the relationships between multiple numerical variables.

This exercise asks you to use the corrplot() function from the corrplot package to visualize this correlation matrix for the numerical variables from the UScereal data frame in the MASS package. Recall that in this version of these plots, ellipses that are thin and elongated indicate a large correlation value between the indicated variables, while ellipses that are nearly circular indicate correlations near zero.

Instructions
100 XP
  • Create a subset of the UScereal data frame that contains only the 9 numerical (i.e., non-factor) variables. Save the result as numericalVars.
  • Apply the cor() function to this subset to compute the correlation matrix containing the correlation coefficients between all variable pairs. Save the result as corrMat.
  • Apply the corrplot() function to display this correlation matrix, using the "ellipse" method.
  • Which two variables are most highly correlated with potassium?