1. Learn
  2. /
  3. Courses
  4. /
  5. Helsinki Open Data Science

Connected

Exercise

Correlations plot

It is often interesting to look at the correlations between variables in the data. The function cor() can be used to create the correlation matrix. A more visual way to look at the correlations is to use corrplot() function (from the corrplot package).

Use the corrplot to visualize the correlation between variables of the Boston dataset.

Instructions

100 XP
  • Calculate the correlation matrix and save it as cor_matrix. Print the matrix to see how it looks like.
  • Adjust the code: use the pipe (%>%) to round the matrix. Rounding can be done with the round() function. Use the first two digits. Print the matrix again.
  • Plot the rounded correlation matrix
  • Adjust the code: add argument type = "upper" to the plot. Print the plot again.
  • Adjust the code little more: add arguments cl.pos = "b", tl.pos = "d" and tl.cex = 0.6 to the plot. Print the plot again.
  • See more of corrplot here