The objective of this assignment is to conduct an exploratory data analysis of a data set that you are not familiar with. In this week’s lecture, we discussed a number of visualization approaches in order to explore a data set with categorical variables. This assignment will apply those tools and techniques. An important distinction between class examples and applied data science work is iterative and repetitive nature of exploring a data set. It takes time to understand what the data is and what is interesting about the data (patterns).
For this week, we will be exploring the Copenhagen Housing Conditions Survey:
Your task for this assignment is to use ggplot and the facet_grid and facet_wrap functions to explore the Copenhagen Housing Conditions Survey. Your objective is to develop 5 report quality visualizations (at least 4 of the visualizations should use the facet_wrap or facet_grid functions) and identify interesting patterns and trends within the data that may be indicative of large scale trends. For each visualization you need to write a few sentences about the trends and patterns that you discover from the visualization.
To submit this homework you will create the document in Rstudio, using the knitr package (button included in Rstudio) and then submit the document to your Rpubs account. Once uploaded you will submit the link to that document on Canvas. Please make sure that this link is hyperlinked and that I can see the visualization and the code required to create it.
str(housing)
## 'data.frame': 72 obs. of 5 variables:
## $ Sat : Ord.factor w/ 3 levels "Low"<"Medium"<..: 1 2 3 1 2 3 1 2 3 1 ...
## $ Infl: Factor w/ 3 levels "Low","Medium",..: 1 1 1 2 2 2 3 3 3 1 ...
## $ Type: Factor w/ 4 levels "Tower","Apartment",..: 1 1 1 1 1 1 1 1 1 2 ...
## $ Cont: Factor w/ 2 levels "Low","High": 1 1 1 1 1 1 1 1 1 1 ...
## $ Freq: int 21 21 28 34 22 36 10 11 36 61 ...
head(housing)
## Sat Infl Type Cont Freq
## 1 Low Low Tower Low 21
## 2 Medium Low Tower Low 21
## 3 High Low Tower Low 28
## 4 Low Medium Tower Low 34
## 5 Medium Medium Tower Low 22
## 6 High Medium Tower Low 36
ggplot(housing, aes(Sat, Freq)) + geom_point() + facet_grid(. ~ Type) + labs( x= 'Satisfaction', y= 'The number of residents', title = 'Plot 1')
# Most people in Copenhagen tend to rent apartments over other types. Only the residents of Terrace have more low satistifaction.
ggplot(housing, aes(Sat, Freq)) + geom_point() + facet_grid(Cont ~ .) + labs( x= 'Satisfaction', y= 'The number of residents', title = 'Plot 2')
#There are more high contact residents than low ones. High contact residents tend to have higher satisfaction
ggplot(housing, aes(Infl, Freq)) + geom_point() + facet_wrap(Type ~ .) + labs( x= 'Influence', y= 'The number of residents', title = 'Plot 3')
# Terrace tends to have more low infulence households than other households.
ggplot(housing, aes(Infl, Freq)) + geom_point() + facet_grid(Cont ~ .) + labs( x= 'Influence', y= 'The number of residents', title = 'Plot 4')
# High contact residents have more low and medium influence
ggplot(housing, aes(Type, Freq)) + geom_point() + facet_grid(Cont ~ .) + labs( x= 'Influence', y= 'The number of residents', title = 'Plot 5')
# More residents of apartment and terrace among high contact residents