Chapter 64 Top Twenty Facility Types

TopFacilityTypes = FoodInspections %>%
  mutate(FacilityType = as.factor(`Facility Type`)) %>%
  select(-(`Facility Type`)) %>%
  filter(!is.na(FacilityType)) %>%
  group_by(FacilityType) %>%
  dplyr::summarise(CountResults = n()) %>%
  arrange(desc(CountResults)) %>%
  mutate(FacilityType = reorder(FacilityType,CountResults)) %>%
  head(20)

TopFacilityTypes %>%
  
  ggplot(aes(x = FacilityType,y = CountResults)) +
  geom_bar(stat='identity',colour="white", fill =fillColor2) +
  geom_text(aes(x = FacilityType, y = 1, label = paste0("(",CountResults,")",sep="")),
            hjust=0, vjust=.5, size = 4, colour = 'black',
            fontface = 'bold') +
  labs(x = 'Results', y = 'CountResults', 
       title = 'Results Analysis') +
  coord_flip() + 
  theme_bw()

Restaurant is the most common Facility type.