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)

Q1 What factors have positve correlation with home price?

Rooms, bathrooms and landvalue

Q2 What factors have strong positve correlation with home price?

Living area has the strongest correlation with home price.

Q3 What factors have negative correlation with home price?

Age is the only negative correlation with home price

Q4 What factors have strong negative correlation with home price?

age has the weaskest correlation with home 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?

Living area and number of rooms

Q7 Plot correlation for CPS85 in the same way as above. Repeat Q1-Q6.

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)

  1. age with exprience, wage with education
  2. age and exprience have the strongest correlation
  3. age and education and experience and education have negative correlation
  4. experience and eduacation have the weakest correlation
  5. Age and experience have the highest correlation between the two varribles

Q8 Hide the messages, the code and its results on the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.