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 ...
View(housing)

1. First plot

ggplot(housing, aes(Freq, Cont)) +
  geom_bar(aes(fill=Infl),stat='identity', position=position_dodge(0.9))+
  facet_grid(Infl ~ ., scales = 'fixed', space = 'fixed') +
  theme(strip.text.y = element_text(angle = 0),
        legend.position = 'none') +
  labs(y = 'Contact with other residents',
       x = 'Numbers of Residents',
       title = 'Number of Resident by contact and influence of Mgmt')

In the above plot, we tried to find the number of residents who have contact with other residents and their influence of management.There are maximum residents with medium influence of management also both highest and lowest contact with residents

2. Second plot

levels(housing$Infl) = list('Influence-High' = 'High', 'Influence-Medium' = 'Medium','Influence-Low' = 'Low')


housing %>%   
  mutate(influence = fct_reorder(Infl,Freq)) %>%
  mutate(Satisfaction = fct_reorder(Sat, -Freq)) %>% 
  ggplot(aes(Freq, influence)) +
   geom_point(aes(color = Satisfaction)) +
   facet_grid(Satisfaction ~ ., scales = "free", space = "free") +
   theme_light() +
   theme(strip.text.y = element_text(angle = 0),
        legend.position = "none") +
   labs(y = "Influence of Management",
       x = "Number of residents",
       title = "Number of residents with Influence and satisfaction")

From the above plot we can understand that the Maximum number of residents have lowest satisfaction level and htey had lowest interaction with management.If the residents have medium influence they have good satisfaction level. ## 3. Third plot

ggplot(housing, aes(x = Cont, y = Freq))+
  geom_bar(
    aes(fill = Sat), stat = "identity", color = "white",
    position = position_dodge(0.9)
    )+
  facet_wrap(~Type) +
    labs(x="Contact with residents",
              y="Number of Residents",
              title="Satisfaction and Number of householders with Type of Accomodation  ")+
  scale_fill_discrete('Satisfaction of Householders')

From the above plot we can conclude that ,when residents have high Contact with other residents then they have high satisfaction level.Maority of residents live in Apartments.People living in Atrium and Tower have Higher level of satisfaction compared ot other ## 4. Fourth plot

# place code for vis here

levels(housing$Sat) = list('Sat-Low' = 'Low', 'Sat-Medium' = 'Medium', 'Sat-High' = 'High')
levels(housing$Cont) = list('Contact-Low' = 'Low', 'Contact-High' = 'High')
ggplot(housing, aes(Freq, Sat)) +
  geom_point(aes(color=Type))+
  facet_grid(Type ~ Cont, space="fixed", scales="fixed") +
  theme(strip.text.y = element_text(angle = 0),
        legend.position = 'none') +
  labs(y = 'Satisfaction',
       x = 'Numbers of Residents',
       title = 'Number of Resident by Satisfaction,Contact with residents, and Type of Accomodation')

From the above plot we can conclude that ,when residents have high Contact with other residents then they have high satisfaction level.Maority of residents live in Apartments and most of them are either satisfied or not at all satisfied.People living in Atrium and Tower have Higher level of satisfaction compared to Terrace ## 5. Fifth plot

library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.0.2
ggballoonplot(housing,x="Cont",y="Sat", size="Freq", facet.by="Type", fill = "Freq")+ scale_fill_viridis_c(option = "B")

From the above plot we can conclude that ,when residents have high Contact with other residents then they have high satisfaction level.Maority of residents live in Apartments and most of them are either satisfied or not at all satisfied.People living in Atrium and Tower have Higher level of satisfaction compared to Terrace