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")

Using method as pie will generate the following figure:

Using method = pie

In the next step we have used the lm function to form a linear regression model. Before that using the attach function we attached our mydata dataset to the search path, hence we can now write Month instead of mydata$Month. We stored the model in reg and printed the summary for reg. It will give us all required values for regression such as residuals, coefficients, errors, and so on. Using the predict function we pass our model and value of ozone concentration to predict the temperature from the dataset.

We create a regression using all the attributes and predict the temperature for given Ozone, Solar.R, and Wind in a given Month.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset