How it works...

This recipe introduces how to create a correlation matrix using corrplot, it displays coefficients in different colors. Before using corrplot we need to remove the factors from the month, we simply replace month in mydata with airquality month. We can generate different visualizations in corrplot by changing method argument to circle, pie, color, shade, ellipse and so on:

> corrplot(cor(mydata),method="color")

Using method as color will generate the following figure:

Using method = color
> corrplot(cor(mydata),method="circle")

Using method as circle will generate the following figure:

Using method = circle
> corrplot(cor(mydata),method="pie") ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.