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.
Este ejercicio forma parte del curso
Helsinki Open Data Science
Instrucciones del ejercicio
- 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 theround()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"andtl.cex = 0.6to the plot. Print the plot again. - See more of corrplot here
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# MASS, corrplot, tidyverse and Boston dataset are available
# calculate the correlation matrix and round it
cor_matrix<-cor(Boston)
# print the correlation matrix
# visualize the correlation matrix
corrplot(cor_matrix, method="circle")