Chapter 50 Time Analysis of Adverse Events
We find the adverse events reports are increasing with each year. Is it because more events are occurring or more events are being reported ?
50.1 Year wise
AdverseFoodEvents %>%
mutate(YearAdverseEvent = year(dmy(StartDate))) %>%
filter(!is.na(YearAdverseEvent)) %>%
filter(YearAdverseEvent > 2000) %>%
group_by(YearAdverseEvent) %>%
summarise(Count = n()) %>%
arrange(YearAdverseEvent) %>%
ungroup() %>%
ggplot(aes(x = YearAdverseEvent,y = Count)) +
geom_bar(stat='identity',colour="white", fill = fillColor) +
labs(x = 'Year of Adverse Event',
y = 'Count',
title = 'Year of Adverse Event and Count') +
theme_bw()
50.2 Most Common Month for Adverse Events
AdverseFoodEvents %>%
mutate(MonthAdverseEvent = month(dmy(StartDate))) %>%
filter(!is.na(MonthAdverseEvent)) %>%
group_by(MonthAdverseEvent) %>%
summarise(Count = n()) %>%
arrange(desc(Count)) %>%
ungroup() %>%
mutate(MonthAdverseEvent = reorder(MonthAdverseEvent,Count)) %>%
ggplot(aes(x = MonthAdverseEvent,y = Count)) +
geom_bar(stat='identity',colour="white", fill = fillColor2) +
geom_text(aes(x = MonthAdverseEvent, y = 1, label = paste0("(",Count,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'Month',
y = 'Count',
title = 'Month and Count') +
coord_flip() +
theme_bw()