Chapter 67 Trend of Inspections Monthwise
We examine the inspections Monthwise in Three different perspectives
- Trend Monthwise for all Results
- Trend Monthwise for all Results in seperate bar plots representing each Result Type
- Trend Monthwise for Out of Business Result
67.1 All Results
We examine the inspections in each of the months.Inspections dip in Nov, Dec which is expected because of the holiday seasons. I do not understand why the inspections dip ubruptly in July.
breaks = seq(1,12,1)
FoodInspections %>%
select(Results,`Inspection Date`) %>%
mutate(Results = as.factor(Results)) %>%
dplyr::rename(InspectionDate = `Inspection Date`) %>%
mutate(month_of_year = month(mdy(InspectionDate))) %>%
group_by(month_of_year,Results) %>%
dplyr::summarise(InspectionsCount = n()) %>%
ggplot(aes(x=month_of_year,y=InspectionsCount, fill=Results)) +
geom_bar(stat = 'identity') +
scale_x_continuous(limits = c(0,13),breaks=breaks ) +
labs(x = 'Month', y = 'Count of Inspections',
title = 'Trend of Inspections') +
theme_bw() + theme(legend.position="top")
67.2 Each Result category
The Out Of Business categories increase in Nov and Dec, though the number of inspections decrease in Nov and Dec. In the next section, lets plot only the Out of Business categories.
FoodInspections %>%
select(Results,`Inspection Date`) %>%
mutate(Results = as.factor(Results)) %>%
dplyr::rename(InspectionDate = `Inspection Date`) %>%
mutate(month_of_year = month(mdy(InspectionDate))) %>%
group_by(month_of_year,Results) %>%
dplyr::summarise(InspectionsCount = n()) %>%
ggplot(aes(x=month_of_year,y=InspectionsCount, fill=Results)) +
geom_bar(stat = 'identity') +
scale_x_continuous(limits = c(0,13),breaks=breaks ) +
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")
67.3 Out of Business Result
FoodInspections %>%
select(Results,`Inspection Date`) %>%
filter(Results == "Out of Business") %>%
dplyr::rename(InspectionDate = `Inspection Date`) %>%
mutate(month_of_year = month(mdy(InspectionDate))) %>%
group_by(month_of_year) %>%
dplyr::summarise(InspectionsCount = n()) %>%
ggplot(aes(x=month_of_year,y=InspectionsCount)) +
geom_bar(stat = 'identity' ,colour="white", fill =fillColor) +
scale_x_continuous(limits = c(0,13),breaks=breaks ) +
labs(x = 'Month', y = 'Count of Inspections',
title = 'Trend of Out of Business Inspections') +
theme_bw() + theme(legend.position="top")