Look up^^ at output to see how to get a clickable table of contents
THIS CHUNK PROCESSES THE DATA, ELIMINATES NA
master <- read.csv("https://raw.githubusercontent.com/vernonkat/Coursework/main/SKU%20Master.csv",fileEncoding="UTF-8-BOM")
typeofgood <- read.csv("https://raw.githubusercontent.com/vernonkat/Coursework/main/SKU%20Usage%20Last%20FY.csv",fileEncoding="UTF-8-BOM")
vendors <- read.csv("https://raw.githubusercontent.com/vernonkat/Coursework/main/WH%20Replenishment%20Last%20FY.csv",fileEncoding="UTF-8-BOM")
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
master <- master %>% drop_na()
typeofgood <- typeofgood %>% drop_na()
vendors <- vendors %>% drop_na()
vendors$Received.Qty <- as.numeric(gsub('[,]', '', vendors$Received.Qty)) ##read this column as numeric (it had commas)
typeofgood$Issued.Quantity <- as.numeric(gsub('[,()]', '', typeofgood$Issued.Quantity)) ##read this column as numeric (it had commas)
levels(typeofgood$ShipToCode) <- c("Drystock","Alcohol","Chocolates/Teas","Perishable","Drystock","Alcohol","Chocolates/Teas","Perishable") ##redo this column's factors (it had different names for the same types of goods)
THE TOP 50% OF VENDORS BY FREQUENCY
library(ggplot2)
##install.packages('summarytools')
#library(summarytools)
k <- summarytools::freq(master$PrimVendorNbr, order = "freq")####used to find by hand the top cumulative 50%
## Registered S3 method overwritten by 'pryr':
## method from
## print.bytes Rcpp
bigvendors <- master[master$PrimVendorNbr%in%c("000092675","007032","200753","000418043","055386","201139","200291","001428","000383364","000302746","200002","2000663","000403992","000003","000364514","000376099","200509"), ] ##narrow down to just those vendors found
bigvendors<-droplevels(bigvendors)
ggplot(bigvendors, aes( x = reorder(PrimVendorNbr,PrimVendorNbr,function(x)-length(x)))) +
geom_bar() +
theme(axis.text.x=element_text(angle = 45))+
ylab("Total Times Shipped") +
xlab("Vendors")+
labs(title = "Top 50% of All Shipping by Vendor", caption = "These 16 vendors represent 50% of all shipping done in 2015")

THE TOP 20 VENDORS THAT SHIPPED US THE MOST QUANTITY
v <- vendors %>% group_by(VendorNbr) %>%
summarize(Received.Qty = sum(Received.Qty)) #summarize the quantity column for each Vendor
v <- v[order(-v$Received.Qty),][1:20,] #use only the top 20 of these summed vendors
ggplot(v,aes(x=VendorNbr,y=Received.Qty)) + geom_bar(stat='identity') +
theme(axis.text.x=element_text(angle = 45)) +
labs(title = "Top 20 Vendors That Shipped to Us", caption = "These 20 represent the top 20 vendors that shipped the most quantity to us")+
ylab("Total Quantity") +
xlab("Vendors")

TOTAL DISTRIBUTION OF LEAD TIMES IN GENERAL
boxplot(master$LeadTime,horizontal=TRUE,main="Distribution of Lead Times Total",xlab="Lead Time (Days)",ylab="All Shipments")

LEAD TIMES BY COMMODITY TYPE
boxplot(LeadTime~Whs,master,main="Lead Times by Commodity",xlab="Commodity Type",ylab="Lead Time",names = c("Undefined","Drystock","Alcohol","Chocolate/Teas","Perishable"))

LEAD TIMES BY COMMODITY ZOOMED IN TO SEE THE BOXES
boxplot(LeadTime~Whs,master,main="Lead Times by Commodity (Zoomed In)",ylim=c(0,50),xlab="Commodity Type",ylab="Lead Time",names = c("Undefined","Drystock","Alcohol","Chocolate/Teas","Perishable"))

LEAD TIMES BY VENDOR
boxplot(LeadTime~PrimVendorNbr,bigvendors,main="Lead Times by Vendor",xlab="",ylab="Lead Time",las=2)

LEAD TIMES BY VENDOR (ZOOMED IN)
boxplot(LeadTime~PrimVendorNbr,bigvendors,main="Lead Times by Vendor (Zoomed in)",xlab="",ylab="Lead Time",las=2,ylim=c(0,50))

NUMBER OF TIMES ORDERED BY TYPE
also an example of multiple graphs in one line
#install.packages("gridExtra")
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
plot1 <- ggplot(typeofgood,aes(x=ShipToCode))+geom_bar()+
ggtitle("Times Each Type was Ordered")+
ylab("Times Ordered") +
xlab("Type of Good")+
theme(axis.text.x=element_text(angle = 25))
plot2 <- ggplot(typeofgood,aes(x=ShipToCode,y=Issued.Quantity))+geom_bar(stat='identity')+
ggtitle("Total Amount of Each Type")+
ylab("Total Amout Shipped") +
xlab("Type of Good")+
theme(axis.text.x=element_text(angle = 25))
grid.arrange(plot1, plot2, ncol=2, nrow = 1)
