Chapter 66 Trend of Inspections YearWise

66.1 All Results

FoodInspections %>%
  select(Results,`Inspection Date`) %>%
  mutate(Results =  as.factor(Results)) %>%
  dplyr::rename(InspectionDate = `Inspection Date`) %>%
  mutate(yr = year(mdy(InspectionDate))) %>%
  
  group_by(yr,Results) %>%
  dplyr::summarise(InspectionsCount = n()) %>%
  
  
  ggplot(aes(x=yr,y=InspectionsCount, fill=Results)) +
  geom_bar(stat = 'identity') +
  labs(x = 'Year', y = 'Count of Inspections', 
       title = 'Trend of Inspections') +
  theme_bw() +  theme(legend.position="top") 

The number of inspections show a very slight increasing trend.

66.2 Each Result Category

We examine the inspections in each of the Years for all Results in seperate bar plots representing each Result Type.The Out of Business is very high in 2013.

FoodInspections %>%
  select(Results,`Inspection Date`) %>%
  mutate(Results =  as.factor(Results)) %>%
  dplyr::rename(InspectionDate = `Inspection Date`) %>%
  mutate(yr = year(mdy(InspectionDate))) %>%
  
  group_by(yr,Results) %>%
  dplyr::summarise(InspectionsCount = n()) %>%
  
  
  ggplot(aes(x=yr,y=InspectionsCount, fill=Results)) +
  geom_bar(stat = 'identity') +
  facet_wrap(~Results, ncol = 2, scales = "free_y") + 
  labs(x = 'Month', y = 'Count of Inspections', 
       title = 'Trend of Inspections') +
  theme_bw() +  theme(legend.position="top")