Week 4 Question 13

A company that sells unisex t-shirts is interested in finding out the color and size of its best-selling t-shirt. The accompanying data file contains the size, color, and quantity of t-shirts that were ordered during the last 1,000 transactions. A portion of the data is shown in the accompanying table.

library(readxl)
## Warning: package 'readxl' was built under R version 4.0.5
myData <- read_excel("Ch3_Q37_Data_File.xlsx")
View(myData)

a-1. Construct a contingency table that shows the total quantity sold for each color and size combination. How many size M red t-shirts were sold?

You can also embed plots, for example:

## , ,  = M
## 
##    
##     Red
##   1  12
##   2   6
##   3  15
##   4  10

112 + 26 + 315+ 410 = 109 Red M t-shirts.

a-2. How many size XL purple t-shirts were sold?

myData1 = myData[which(myData$Size == "XL" & myData$Color == "Purple"), ]
tn = table(myData1$Quantity, myData1$Color , myData1$Size)
tn
## , ,  = XL
## 
##    
##     Purple
##   1      9
##   2      9
##   3      6
##   4      9

19 + 29 + 39 + 49 = 90 Purple XL t-shirts.

Look at the heat map and the lowest value is the red cell the highest is the greenest.