Chapter 51 Products in Adverse Events for January
We investigate the month of January since this accounts for the largest number of adverse events.
AdverseFoodEvents %>%
mutate(MonthAdverseEvent = month(dmy(StartDate))) %>%
filter(MonthAdverseEvent == 1) %>%
filter(ProductName != "REDACTED") %>%
PlotProducts(fillColorName = fillColor2)
We find that Wen Cleansing Conditioner is the product which caused the maximum number of adverse events.
PlotSymptoms = function(ds, fillColorName = fillColor)
{
Symptoms = str_split(ds$Symptoms,',')
AllSymptoms <- data.frame(matrix(unlist(Symptoms),byrow=T),stringsAsFactors=FALSE)
colnames(AllSymptoms) = c("SymptomName")
#trimws returns a character string with leading and/or trailing whitespaces removed.
AllSymptoms$SymptomName = trimws(AllSymptoms$SymptomName)
AllSymptoms %>%
group_by(SymptomName) %>%
summarise(Count = n()) %>%
arrange(desc(Count)) %>%
ungroup() %>%
mutate(SymptomName = reorder(SymptomName,Count)) %>%
head(10) %>%
ggplot(aes(x = SymptomName,y = Count)) +
geom_bar(stat='identity',colour="white", fill = fillColorName) +
geom_text(aes(x = SymptomName, y = 1, label = paste0("(",Count,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'Symptom',
y = 'Count',
title = 'Symptom and Count') +
coord_flip() +
theme_bw()
}
51.1 Wen Cleansing Conditioner Symptoms
WenEvents = AdverseFoodEvents %>%
filter(ProductName == 'WEN CLEANSING CONDITIONER')
PlotSymptoms(WenEvents,fillColorName = fillColor2)
51.2 Vitamin D Symptoms
VitDEvents = AdverseFoodEvents %>%
filter(ProductName == 'VITAMIN D')
PlotSymptoms(VitDEvents,fillColorName = fillColor)
51.3 Hydroxycut Symptoms
HydroxycutEvents = AdverseFoodEvents %>%
filter(str_detect(ProductName,'HYDROXYCUT'))
PlotSymptoms(HydroxycutEvents,fillColorName = fillColor)
51.4 MultiVitamin Symptoms
VitDEvents = AdverseFoodEvents %>%
filter(ProductName == 'MULTI VITAMIN')
PlotSymptoms(VitDEvents,fillColorName = fillColor)
51.5 Fish Oil Symptoms
ProductEvents = AdverseFoodEvents %>%
filter(ProductName == 'FISH OIL')
PlotSymptoms(ProductEvents,fillColorName = fillColor2)