Objectives

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.

Look at the data

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

1. First plot

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. 

2. Second plot

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

3. Third plot

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.

4. Fourth plot

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

5. Fifth plot

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