In this exercise you will learn to visualize the pairwise relationships between a set of quantitative variables. To this end, you will make your own note of 8.1 Correlation plots from Data Visualization with R.
# import data
data(SaratogaHouses, package="mosaicData")
# select numeric variables
df <- dplyr::select_if(SaratogaHouses, is.numeric)
# calulate the correlations
r <- cor(df, use="complete.obs")
round(r,2)
library(ggplot2)
library(ggcorrplot)
# visualize the correlations
ggcorrplot(r,
hc.order = TRUE,
type = "lower",
lab = TRUE)
The more Fire places a home has the more expensive it will be.
More Living spaces, are related to higher home prices. More bathrooms rises home price. The bigger the house the more expensive it gets. ## Q3 What factors have negative correlation with home price? The older the house the less expensive it is. Weak relationship ## Q4 What factors have strong negative correlation with home price? NO facors taht have strong negative corallation to price. ## Q5 What set of two variables has the highest positive Pearson Product-Moment correlation coefficient? What set of two variables has the greatest negative Pearson Product-Moment correlation coefficient? postive- Living area and # of rooms postive coraltion .73 Negative- Strongest negative corallation age and bathrooms.
Hint: The CPS85 data set is from the mosaicData package. Explain wage instead of home price.
# import data
data( CPS85, package="mosaicData")
# select numeric variables
df <- dplyr::select_if( CPS85, is.numeric)
# calulate the correlations
r <- cor(df, use="complete.obs")
round(r,2)
library(ggplot2)
library(ggcorrplot)
# visualize the correlations
ggcorrplot(r,
hc.order = TRUE,
type = "lower",
lab = TRUE)
Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide. Q1- Age Q2-Experience Q3-none Q4- experience Q5-wage experience ## Q9 Display the title and your name correctly at the top of the webpage.