2024-09-03

Method of data retrieval

File downloaded from FDA Drug Shortages as of 9/2/2024

library(readr)
current.drug.shortages <- read_csv("~/Documents/MSQM/02 R/Week 2 Challenge/Drugshortages.csv")
company.shortages <- table(current.drug.shortages$`Company Name`)

Basic statistics

Average number of shortages

round(mean(data.frame(company.shortages)$Freq))
## [1] 14

Median number of shortages

round(median(data.frame(company.shortages)$Freq))
## [1] 4

Mode number of shortages

mode.shortages <- data.frame(table(data.frame(table(current.drug.shortages$`Company Name`))$Freq))
as.vector(mode.shortages$Var1)[mode.shortages$Freq==max(mode.shortages$Freq)]
## [1] "1"

Company with the most shortages

most.shortages <- names(company.shortages)[company.shortages==max(company.shortages)]

print(most.shortages)
## [1] "Hospira, Inc., a Pfizer Company"

Company with the most shortages

List of reasons of shortage and the products under that reason

##                                           Reason No. of products
## 1                  Delay in shipping of the drug              41
## 2                   Demand increase for the drug              40
## 3 Discontinuation of the manufacture of the drug               5