Chapter 43 Ten Most Common Product Name
We examine the Top Most Common Products associated with the Adverse Events and plot them in the bar plot.
AdverseFoodEvents %>%
group_by(ProductName) %>%
summarise(Count = n()) %>%
arrange(desc(Count)) %>%
ungroup() %>%
mutate(ProductName = reorder(ProductName,Count)) %>%
head(10) %>%
ggplot(aes(x = ProductName,y = Count)) +
geom_bar(stat='identity',colour="white", fill = fillColor2) +
geom_text(aes(x = ProductName, y = 1, label = paste0("(",Count,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'Product',
y = 'Count',
title = 'Product and Count') +
coord_flip() +
theme_bw()