SELECT *
FROM suppliers s
LEFT JOIN products p
USING(SupplierID)
LEFT JOIN categories c
USING(CategoryID)
LEFT JOIN orderdetails od
USING(ProductID)
LEFT JOIN orders o
USING(OrderID);suppliers_data ke dalam database| Name | suppliers_data |
| Number of rows | 518 |
| Number of columns | 15 |
| _______________________ | |
| Column type frequency: | |
| character | 12 |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| SupplierName | 0 | 1 | 8 | 38 | 0 | 29 | 0 |
| ContactName | 0 | 1 | 10 | 26 | 0 | 29 | 0 |
| Address | 0 | 1 | 12 | 45 | 0 | 29 | 0 |
| City | 0 | 1 | 4 | 13 | 0 | 29 | 0 |
| PostalCode | 0 | 1 | 3 | 8 | 0 | 29 | 0 |
| Country | 0 | 1 | 2 | 11 | 0 | 16 | 0 |
| Phone | 0 | 1 | 8 | 15 | 0 | 29 | 0 |
| ProductName | 0 | 1 | 4 | 32 | 0 | 77 | 0 |
| Unit | 0 | 1 | 5 | 20 | 0 | 70 | 0 |
| CategoryName | 0 | 1 | 7 | 14 | 0 | 8 | 0 |
| Description | 0 | 1 | 7 | 58 | 0 | 8 | 0 |
| OrderDate | 0 | 1 | 10 | 10 | 0 | 160 | 0 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| SupplierID | 0 | 1 | 14.52 | 8.10 | 1.0 | 8 | 14 | 21.00 | 29.0 | ▅▇▆▅▆ |
| Price | 0 | 1 | 29.21 | 33.90 | 2.5 | 13 | 20 | 34.80 | 263.5 | ▇▁▁▁▁ |
| Quantity | 0 | 1 | 24.60 | 18.38 | 1.0 | 10 | 20 | 32.75 | 120.0 | ▇▃▂▁▁ |
Recency_Supplier <- suppliers_data[,c("OrderDate","SupplierID","SupplierName")] %>%
filter(OrderDate >= "1997-01-12") %>%
distinct()
supplier1 <- Recency_Supplier$SupplierName %>% unique()
plots1 <- Recency_Supplier %>%
group_by(SupplierName) %>%
summarise(LastOrder=max(OrderDate)) %>%
ggplot() +
aes(x = LastOrder, y=SupplierName) +
geom_tile(size = 1) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
theme(axis.title = element_text(size = 16),
axis.text = element_text(size = 10)
)
plots124 Nama di atas merupakan supplier yang memenuhi standard recency, yaitu melakukan transaksi dalam sebulan terakhir, sehingga memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
Recency_Country <- suppliers_data[,c("OrderDate", "Country")] %>%
filter(OrderDate >= "1997-01-12") %>%
distinct()
country1 <- Recency_Country$Country %>% unique()
plotc1 <- ggplotly(Recency_Country %>%
group_by(Country) %>%
summarise(LastOrder=max(OrderDate)) %>%
ggplot() +
aes(x = LastOrder, y = Country, fill = Country) +
geom_tile(size = 1) +
theme_minimal() +
theme(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
theme(axis.title = element_text(size = 16),
axis.text = element_text(size = 10)
))
plotc114 negara di atas merupakan negara yang memenuhi standard recency, yaitu melakukan transaksi dalam sebulan terakhir, sehingga supplier dari negara terkait memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
Recency_Product <- suppliers_data[,c("OrderDate", "ProductName")] %>%
filter(OrderDate >= "1997-01-12") %>%
distinct()
product1 <- Recency_Product$ProductName %>% unique()
plotp1 <- ggplotly(Recency_Product %>%
group_by(ProductName) %>%
summarise(LastOrder=max(OrderDate)) %>%
ggplot() +
aes(x = LastOrder, y = ProductName, fill=ProductName) +
geom_tile(size = 1) +
theme_minimal() +
theme(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
theme(axis.title = element_text(size = 16),
axis.text = element_text(size = 10)
))
plotp146 produk di atas merupakan produk yang memenuhi standard recency, yaitu dibeli dalam sebulan terakhir, sehingga produk terkait memiliki kemungkinan lebih besar untuk memproduksi lagi.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.00 11.00 17.00 17.86 20.00 42.00
Kuartil ketiga dari total transaksi supplier adalah 20 kali transaksi.
Supplier dengan total transaksi di atas 20 adalah
Frequency_Supplier <- freq_supp %>%
filter(Quantity >= 20)
supplier2 <- Frequency_Supplier$SupplierName
plots2 <- ggplotly(ggplot(Frequency_Supplier)+
aes(x = SupplierName, fill = Quantity, weight = Quantity) +
geom_bar() +
scale_fill_distiller(palette = "YlGnBu", direction = 1) +
labs(y = "Quantity") +
coord_flip() +
theme_minimal() +
theme(axis.title = element_text(size = 18),
axis.text = element_text(size = 10)
))
plots29 Nama di atas merupakan supplier yang memenuhi standard frequency, yaitu memiliki total transaksi diatas 20 transaksi, sehingga memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.00 15.50 30.50 32.38 51.75 65.00
Kuartil ketiga dari total transaksi tiap negara adalah 51.75 kali transaksi.
Negara dengan total transaksi di atas 51.75 adalah
Frequency_Country <- freq_coun %>%
filter(Quantity >= 51.75)
country2 <- Frequency_Country$Country
plotc2 <- ggplotly(ggplot(Frequency_Country)+
aes(x = Country, fill = Quantity, weight = Quantity) +
geom_bar() +
scale_fill_distiller(palette = "YlGnBu", direction = 1) +
labs(y = "Quantity") +
coord_flip() +
theme_minimal() +
theme(axis.title = element_text(size = 18),
axis.text = element_text(size = 10)
))
plotc24 Negara di atas merupakan negara yang memenuhi standard frequency, yaitu memiliki total transaksi diatas 51.75 transaksi, sehingga memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.000 3.000 7.000 6.727 9.000 14.000
Kuartil ketiga dari total transaksi tiap produk adalah 9 kali transaksi.
produk dengan total transaksi di atas 9 adalah
Frequency_Product <- freq_prod %>%
filter(Quantity >= 9)
product2 <- Frequency_Product$ProductName
plotp2 <- ggplotly(ggplot(Frequency_Product)+
aes(x = ProductName, fill = Quantity, weight = Quantity) +
geom_bar() +
scale_fill_distiller(palette = "YlGnBu", direction = 1) +
labs(y = "Quantity") +
coord_flip() +
theme_minimal() +
theme(axis.title = element_text(size = 18),
axis.text = element_text(size = 10)
))
plotp225 produk di atas merupakan produk yang memenuhi standard frequency, yaitu memiliki total transaksi diatas 9, sehingga produk terkait memiliki kemungkinan lebih besar untuk diproduksi lagi.
suppliers_data[,c("SupplierID", "SupplierName", "Quantity")] %>%
group_by(SupplierID) %>%
summarise(Quantity=sum(Quantity)) %>%
summary()## SupplierID Quantity
## Min. : 1 Min. : 155.0
## 1st Qu.: 8 1st Qu.: 209.0
## Median :15 Median : 431.0
## Mean :15 Mean : 439.4
## 3rd Qu.:22 3rd Qu.: 518.0
## Max. :29 Max. :1148.0
Kuartil ketiga dari total unit produksi supplier adalah 518 unit.
Supplier dengan total unit produksi diatas 518
Quantity_Supplier <- suppliers_data[,c("SupplierName", "Quantity")] %>%
group_by(SupplierName) %>%
summarise(Quantity=sum(Quantity)) %>%
filter(Quantity >=518)
supplier3 <- Quantity_Supplier$SupplierName
plots3 <- ggplotly(ggplot(Quantity_Supplier)+
aes(x = SupplierName, fill = Quantity, weight = Quantity) +
geom_bar() +
scale_fill_distiller(palette = "YlGnBu", direction = 1) +
labs(y = "Quantity") +
coord_flip() +
theme_minimal() +
theme(axis.title = element_text(size = 18),
axis.text = element_text(size = 10)
))
plots38 Nama di atas merupakan supplier yang memenuhi standard Monetary, yaitu memiliki total unit produksi diatas 518 unit, sehingga memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 9.2 182.1 431.0 746.0 822.2 13175.0
Kuartil ketiga dari total jumlah produksi supplier adalah 822.2
Supplier dengan total jumlah produksi di atas $822.2 adalah
Total_Supplier <- supp_total %>%
filter(Total >= 822.2)
supplier4 <- Total_Supplier$SupplierName
plots4 <- suppliers_data %>%
group_by(SupplierID,SupplierName) %>%
summarise(income = sum(Price*Quantity)) %>%
ungroup()%>%
filter(income >= 822.2) %>%
mutate(Supplier = as.factor(SupplierName),
detail = glue("Profit : ${income}")) %>%
ggplot(aes(x = Supplier,
y = income)) +
geom_bar(aes(fill = income,
text = detail),
show.legend = T,
stat = "identity") +
labs(title = "",
x = NULL,
y = "Income") +
coord_flip()+
theme_minimal()+
scale_fill_gradient(low = "#afeeee", high = "#191970")
ggplotly(plots4, tooltip = "detail")## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 158.0 345.5 698.0 796.4 1247.5 1610.0
Kuartil ketiga dari total unit produksi negara adalah 1247.5 unit.
Negara dengan total unit produksi diatas 1247.5
Quantity_Country <- suppliers_data[,c("Country", "Quantity")] %>%
group_by(Country) %>%
summarise(Quantity=sum(Quantity)) %>%
filter(Quantity >=1247.5)
country3 <- Quantity_Country$Country
plotc3 <- ggplotly(ggplot(Quantity_Country)+
aes(x = Country, fill = Quantity, weight = Quantity) +
geom_bar() +
scale_fill_distiller(palette = "YlGnBu", direction = 1) +
labs(y = "Quantity") +
coord_flip() +
theme_minimal() +
theme(axis.title = element_text(size = 18),
axis.text = element_text(size = 10)
))
plotc34 Negara di atas merupakan negara yang memenuhi standard Monetary, yaitu memiliki total unit produksi diatas 1247.5 unit, sehingga memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 711 6698 12773 24152 30681 103468
Kuartil ketiga dari total jumlah produksi negara adalah 30681
Supplier dengan total jumlah produksi di atas $30681 adalah
Total_Country <- coun_total %>%
filter(Total >= 30681)
country4 <- Total_Country$Country
plotc4 <- suppliers_data %>%
group_by(Country) %>%
summarise(income = sum(Price*Quantity)) %>%
ungroup()%>%
filter(income >= 30681) %>%
mutate(Country = as.factor(Country),
detail = glue("Profit : ${income}")) %>%
ggplot(aes(x = Country,
y = income)) +
geom_bar(aes(fill = income,
text = detail),
show.legend = T,
stat = "identity") +
labs(title = "",
x = NULL,
y = "Income") +
coord_flip()+
theme_minimal()+
scale_fill_gradient(low = "#afeeee", high = "#191970")
ggplotly(plotc4, tooltip = "detail")4 Negara di atas merupakan negara yang memenuhi standard Monetary, yaitu memiliki total jumlah pembelian di atas 30681, sehingga memiliki kemungkinan lebih besar untuk melakukan transaksi lagi.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.0 90.0 159.0 165.5 209.0 458.0
Kuartil ketiga dari total unit produk adalah 209.0 unit.
produk dengan total unit produksi diatas 209.0
Quantity_Product <- suppliers_data[,c("ProductName", "Quantity")] %>%
group_by(ProductName) %>%
summarise(Quantity=sum(Quantity)) %>%
filter(Quantity >=209.0)
product3 <- Quantity_Product$ProductName
plotp3 <- ggplotly(ggplot(Quantity_Product)+
aes(x = ProductName, fill = Quantity, weight = Quantity) +
geom_bar() +
scale_fill_distiller(palette = "YlGnBu", direction = 1) +
labs(y = "Quantity") +
coord_flip() +
theme_minimal() +
theme(axis.title = element_text(size = 18),
axis.text = element_text(size = 10)
))
plotp320 produk di atas merupakan produk yang memenuhi standard Monetary, yaitu memiliki total unit pembelian di atas 20, sehingga produk terkait memiliki kemungkinan lebih besar untuk diproduksi lagi.
Selanjutnya kita akan menggabungkan seluruh hasil analisis kita.
supplierRFM <- c(supplier1, supplier2, supplier3, supplier4) %>% unique()
data.frame(Supplier=supplierRFM)## Supplier
## 1 Mayumi's
## 2 Exotic Liquid
## 3 Forêts d'érables
## 4 Karkki Oy
## 5 Specialty Biscuits, Ltd.
## 6 Norske Meierier
## 7 Pavlova, Ltd.
## 8 G'day, Mate
## 9 Pasta Buttini s.r.l.
## 10 Aux joyeux ecclésiastiques
## 11 Lyngbysild
## 12 Plutzer Lebensmittelgroßmärkte AG
## 13 Zaanse Snoepfabriek
## 14 Tokyo Traders
## 15 Gai pâturage
## 16 Svensk Sjöföda AB
## 17 Heli Süßwaren GmbH & Co. KG
## 18 Formaggi Fortini s.r.l.
## 19 Bigfoot Breweries
## 20 Ma Maison
## 21 New England Seafood Cannery
## 22 Cooperativa de Quesos 'Las Cabras'
## 23 PB Knäckebröd AB
## 24 New Orleans Cajun Delights
## 25 Nord-Ost-Fisch Handelsgesellschaft mbH
## 26 Leka Trading
## 27 Grandma Kelly's Homestead
## 28 Escargots Nouveaux
## Country
## 1 Japan
## 2 UK
## 3 Canada
## 4 Finland
## 5 Norway
## 6 Australia
## 7 Italy
## 8 France
## 9 Denmark
## 10 Germany
## 11 Netherlands
## 12 Sweden
## 13 USA
## 14 Spain
## product
## 1 Tofu
## 2 Chais
## 3 Tarte au sucre
## 4 Lakkalikööri
## 5 Teatime Chocolate Biscuits
## 6 Geitost
## 7 Alice Mutton
## 8 Perth Pasties
## 9 Ravioli Angelo
## 10 Côte de Blaye
## 11 Spegesild
## 12 Scottish Longbreads
## 13 Original Frankfurter grüne Soße
## 14 Chang
## 15 Zaanse koeken
## 16 Sirop d'érable
## 17 Longlife Tofu
## 18 Camembert Pierrot
## 19 Gudbrandsdalsost
## 20 Mishi Kobe Niku
## 21 Konbu
## 22 Outback Lager
## 23 Röd Kaviar
## 24 Gumbär Gummibärchen
## 25 Gorgonzola Telino
## 26 Raclette Courdavault
## 27 Steeleye Stout
## 28 Pâté chinois
## 29 Gnocchi di nonna Alice
## 30 Wimmers gute Semmelknödel
## 31 Valkoinen suklaa
## 32 Vegie-spread
## 33 Sir Rodney's Scones
## 34 Boston Crab Meat
## 35 Tourtière
## 36 Queso Cabrales
## 37 Gustaf's Knäckebröd
## 38 Mozzarella di Giovanni
## 39 Rhönbräu Klosterbier
## 40 Sasquatch Ale
## 41 Queso Manchego La Pastora
## 42 Pavlova
## 43 Thüringer Rostbratwurst
## 44 Schoggi Schokolade
## 45 Louisiana Hot Spiced Okra
## 46 Rössle Sauerkraut
## 47 Fløtemysost
## 48 Guaraná Fantástica
## 49 Inlagd Sill
## 50 Jack's New England Clam Chowder
## 51 Louisiana Fiery Hot Pepper Sauce
## 52 Chartreuse verte
SELECT Country, Quantity, Price, (Quantity*Price) AS Total, COUNT(SupplierName) AS Total_Supplier_Per_Country
FROM suppliers_data
GROUP BY Country## Country Quantity Price Total Total_Supplier_Per_Country
## 1 Australia 40 53.00 2120.00 59
## 2 Brazil 15 4.50 67.50 11
## 3 Canada 21 24.00 504.00 34
## 4 Denmark 15 12.00 180.00 8
## 5 Finland 40 20.00 800.00 19
## 6 France 40 34.00 1360.00 45
## 7 Germany 12 13.00 156.00 65
## 8 Italy 5 34.80 174.00 51
## 9 Japan 9 23.25 209.25 29
## 10 Netherlands 16 9.50 152.00 4
## 11 Norway 25 2.50 62.50 32
## 12 Singapore 10 14.00 140.00 17
## 13 Spain 12 21.00 252.00 11
## 14 Sweden 6 21.00 126.00 20
## 15 UK 40 81.00 3240.00 54
## 16 USA 10 9.65 96.50 59
##
## Call:
## lm(formula = Total ~ Quantity, data = data_total)
##
## Residuals:
## Min 1Q Median 3Q Max
## -905.3 -253.8 0.3 212.3 1534.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -473.13 265.74 -1.780 0.096706 .
## Quantity 54.46 11.33 4.807 0.000279 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 573.4 on 14 degrees of freedom
## Multiple R-squared: 0.6227, Adjusted R-squared: 0.5958
## F-statistic: 23.11 on 1 and 14 DF, p-value: 0.0002789
p-value dari model linier di atas lebih kecil dari 0.05 (tingkat kesalahan 5%), yang membuktikan bahwa terdapat hubungan linier antara Kuantitas dan jumlah total produksi. Model liniernya adalah sebagai berikut:
\[Total = -473.13+54.46 \times Quantity\]
##
## Call:
## lm(formula = Quantity ~ Price, data = data_total)
##
## Residuals:
## Min 1Q Median 3Q Max
## -18.8733 -6.3756 -0.6712 4.0530 21.5632
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.0901 4.4201 2.509 0.0250 *
## Price 0.3673 0.1451 2.532 0.0239 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.2 on 14 degrees of freedom
## Multiple R-squared: 0.3141, Adjusted R-squared: 0.2651
## F-statistic: 6.412 on 1 and 14 DF, p-value: 0.02393
p-value dari model linier di atas lebih kecil dari 0.05 (tingkat kesalahan 5%), yang membuktikan bahwa terdapat hubungan linier antara Kuantitas dan harga produksi. Model liniernya adalah sebagai berikut:
\[Quantity = 11.0901+0.3673 \times Price\]
##
## Call:
## lm(formula = Quantity ~ Total_Supplier_Per_Country, data = data_total)
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.742 -10.596 -1.075 7.976 22.399
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.5485 6.2414 2.331 0.0352 *
## Total_Supplier_Per_Country 0.1607 0.1642 0.979 0.3444
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 13.09 on 14 degrees of freedom
## Multiple R-squared: 0.06402, Adjusted R-squared: -0.002835
## F-statistic: 0.9576 on 1 and 14 DF, p-value: 0.3444
p-value dari model linier di atas lebih besar dari 0.05 (tingkat kesalahan 5%), yang membuktikan bahwa tidak terdapat hubungan linier antara jumlah supplier pada suatu negara dan kuantitas penjualan.
Dari data RFM yang kita peroleh diatas, dapat kita lihat terdapat ada supplier, negara, dan produk yang memenuhi standard Recency Frequency dan Monetary yaitu kuartil 3 diatas dimana berarti seorang supplier dan negara diharapkan untuk memproduksi lebih banyak barang dan ada barang yang diharapkan lebih banyak di produksi. Terdapat 28 Supplier, 14 Negara, dan 52 produk yang memenuhi standard RFM.
Dari sisi 28 supplier yang memenuhi standar RFM maka mereka dapat meningkatkan produksi dan penyaluran suatu barang kepada konsumen. 14 negara yang memiliki nilai diatas standart RFM juga dapat melakukan impor barang untuk mencari informasi kelarisan produk negaranya di negara lain. 52 produk yang memenuhi standard RFM dapat dipertimbangkan harganya kembali untuk mencari keuntungan semaksimal mungkin.