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(x = Sat, y = Freq))+geom_boxplot(outlier.color = 'black',outlier.shape = 15,outlier.size = 2,notch = FALSE)+facet_grid(~Type)+
  labs(title="Number of Resident by Satisfaction with their Rental Type")+
  xlab("Satisfaction")+
  ylab("Number of Resident")

comment:

Using, the face_grid, We can check their satisfaction per each housing type and their overall quantity using the same scale on the ylim. it looks like The apartment, Tower and Atrium type has the higher satisfaction. In terms of the low satifaction, we can pinpoint the apartment also have more low satifaction cases compare to other housing types.

2. Second plot

ggplot(housing, aes(x = Infl,y = Freq))+
  geom_bar(
    aes(fill=Cont),stat='identity',color = 'white', position = position_dodge(0.9)
  )+
  facet_wrap(~Type)+
  labs(title="Number of Resident by perceived degree of influence householders with their Rental Type")+
  xlab("perceived degree of influence householders (Infl)")+
  ylab("Number of Resident")

comment:

Then, I use the facet_wrap to visualize the Contract type for each type of housing Influence.

3. Third plot

# place code for vis here
ggplot(housing, aes(x = Cont,y = Freq))+
  geom_point(shape=1)+
  facet_grid(~Type)+
  labs(title="Scatter Plots for Number of Resident by perceived degree of Contract type with their Rental Type")+
  xlab("Contract type (Cont)")+
  ylab("Number of Resident")

comment: These scatter plots show their type of contract residents afforded with other residents per their housing Type.

4. Fourth plot

# place code for vis here
ggplot(housing, aes(x = Type,y = Freq))+
  geom_point(shape=1)+
  facet_grid(~Sat)+
  labs(title="Scatter Plots for each satisfaction scenarios per housing type")

comment: In this plots. We can see in each satisfaction type. how this distribution per housing type.

5. Fifth plot

# place code for vis here
data1<- housing %>%group_by(Sat,Infl,Type)%>%
  summarise(Freq = sum(Freq))
ggpubr::ggballoonplot(data1,x = 'Infl',y = 'Sat',size = 'Freq',col = 'Infl',facet.by = 'Type',fill = 'Infl')+
  labs(title="Balloonplot for degree of influence householders with their Satisfaction")

comment: These balloonplot provide another visual idea of the different Influence per satisfaction. The size of the circle represent the frequency of each type.