LAPORAN TUGAS SIM

Mengimpor dataset Coffee Chain

library(readxl)
## Warning: package 'readxl' was built under R version 4.5.2
coffeechain=read_excel("D:\\My Documents\\AA UNS\\SIM\\1. Tugas SIM 2025B - Coffee Chain Datasets.xlsx")

INSIGHT 1: Hubungan Biaya Pemasaran terhadap Keuntungan

Insight ini bertujuan untuk mengetahui hubungan antara biaya pemasaran (Marketing) yang digunakan dengan keuntungan (Profit) yang dihasilkan.

library(ggplot2)

# Visualisasi: Scatter Plot Marketing vs Profit
ggplot(coffeechain, aes(x = Marketing, y = Profit, color= Market)) +
  geom_point(alpha = 0.6, size = 2) +
  geom_smooth(method = "lm", se = FALSE, linetype = "dashed", color = "black") +
  labs(title = "Hubungan Biaya Pemasaran (Marketing) terhadap Keuntungan (Profit)",
       subtitle = "Coffee Chain Dataset",
       x = "Biaya Marketing",
       y = "Keuntungan (Profit)",
       color = "Wilayah") +
  theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

Visualisasi scatter plot menunjukkan bahwa terdapat korelasi positif antara biaya pemasaran dengan keuntungan. Hal ini terlihat dari arah sebaran titik data dan garis tren yang bergerak dari kiri bawah ke kanan atas. Penggunaan warna berdasarkan wilayah mengungkapkan bahwa efektivitas pemasaran bervariasi di tiap pasar, di mana wilayah tertentu mampu menghasilkan profit lebih tinggi pada tingkat biaya marketing yang sama dibandingkan wilayah lainnya.

INSIGHT 2: Perbandingan Rata-rata Profit Lini Produk (Beans vs Leaves)

Insight ini bertujuan untuk mengetahui perbandingan keuntungan rata-rata dari lini produk Beans dan Leaves.

library(ggplot2)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.2
## 
## 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
#Rata-rata profit per Product Line
rata_rata_profit <- coffeechain %>%
  group_by(`Product Line`) %>%
  summarise(Mean_Profit = mean(Profit, na.rm = TRUE),
            SD_Profit = sd(Profit, na.rm = TRUE))

#Visualisasi: Bar Chart Rata-rata
ggplot(rata_rata_profit, aes(x = `Product Line` , y = Mean_Profit, fill = `Product Line`)) +
  geom_bar(stat = "identity", width = 0.5, alpha = 0.8) +
  geom_text(aes(label = round(Mean_Profit, 2)), vjust = -0.5) +
  labs(title = "Perbandingan Rata-rata Profit: Beans vs Leaves",
       x = "Lini Produk",
       y = "Rata-rata Profit ($)") +
  theme_minimal() 

Visualisasi bar chart menunjukkan adanya perbedaan keuntungan rata-rata antara lini produk Beans dengan Leaves. Lini produk kategori Beans (Coffee) memiliki rata-rata keuntungan yang lebih tinggi, yaitu sebesar 64.2 dollar. Sementara itu, kategori Leaves (Tea) memiliki rata-rata yang lebih rendah, yaitu 57.66 dollar. Lini produk Beans memiliki performa penjualan yang lebih tinggi dibandingkan Leaves. Hal tersebut menunjukkan bahwa lini produk Beans memberikan kontribusi yang lebih besar bagi keuntungan perusahaan.

INSIGHT 3: Persentase Kontribusi Profit Leaves (Tea) per Market

Insight ini bertujuan untuk mengetahui seberapa besar persentase kontribusi tiap market (Central, East, South, dan West) terhadap keuntungan lini produk Leaves (Tea) yang diperoleh perusahaan.

library(ggplot2)
library(dplyr)

#Menghitung data khusus Leaves dan total profit per market
data_pie <- coffeechain %>%
  filter(`Product Line` == "Leaves") %>% 
  group_by(Market) %>%
  summarise(Total_Profit = sum(Profit, na.rm = TRUE)) %>%
  mutate(Persen = Total_Profit / sum(Total_Profit) * 100,
         Label = paste0(Market, "\n", round(Persen, 1), "%"))

#Visualisasi: Pie Chart
ggplot(data_pie, aes(x = "", y = Total_Profit, fill = Market)) +
  geom_bar(stat = "identity", width = 1) +
  coord_polar("y", start = 0) + 
  geom_text(aes(label = Label), position = position_stack(vjust = 0.5), color = "white") +
  labs(title = "Kontribusi Profit Lini Produk Teh per Market",
       subtitle = "Persentase berdasarkan Total Profit Leaves (Tea)") +
  theme_void() 

Visualisasi pie chart menunjukkan seberapa besar kontribusi suatu market terhadap keuntungan lini produk Leaves (Tea). Berdasarkan hasil visualisasi, dapat dilihat bahwa Market Central memiliki kontribusi terbanyak, yaitu sebesar 40.5%. Sementara itu, kontribusi terkecil dimiliki oleh Market South, sebesar 5%.

Analisis Statistika Deskriptif dari Dataset Coffee Chain

summary(coffeechain)
##    Area Code          Date                        Market         
##  Min.   :203.0   Min.   :2012-01-01 00:00:00   Length:4248       
##  1st Qu.:417.0   1st Qu.:2012-06-23 12:00:00   Class :character  
##  Median :573.0   Median :2012-12-16 12:00:00   Mode  :character  
##  Mean   :582.3   Mean   :2012-12-15 22:00:00                     
##  3rd Qu.:772.0   3rd Qu.:2013-06-08 12:00:00                     
##  Max.   :985.0   Max.   :2013-12-01 00:00:00                     
##  Market Size          Product          Product Line       Product Type      
##  Length:4248        Length:4248        Length:4248        Length:4248       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##     State               Type            Budget COGS     Budget Margin   
##  Length:4248        Length:4248        Min.   :  0.00   Min.   :-210.0  
##  Class :character   Class :character   1st Qu.: 30.00   1st Qu.:  50.0  
##  Mode  :character   Mode  :character   Median : 50.00   Median :  70.0  
##                                        Mean   : 74.83   Mean   : 100.8  
##                                        3rd Qu.: 90.00   3rd Qu.: 130.0  
##                                        Max.   :450.00   Max.   : 690.0  
##  Budget Profit      Budget Sales         COGS          Inventory      
##  Min.   :-320.00   Min.   :   0.0   Min.   :  0.00   Min.   :-3534.0  
##  1st Qu.:  20.00   1st Qu.:  80.0   1st Qu.: 43.00   1st Qu.:  432.0  
##  Median :  40.00   Median : 130.0   Median : 60.00   Median :  619.0  
##  Mean   :  60.91   Mean   : 175.6   Mean   : 84.43   Mean   :  749.4  
##  3rd Qu.:  80.00   3rd Qu.: 210.0   3rd Qu.:100.00   3rd Qu.:  910.5  
##  Max.   : 560.00   Max.   :1140.0   Max.   :364.00   Max.   : 8252.0  
##      Margin          Marketing          Profit           Sales    
##  Min.   :-302.00   Min.   :  0.00   Min.   :-638.0   Min.   : 17  
##  1st Qu.:  52.75   1st Qu.: 13.00   1st Qu.:  17.0   1st Qu.:100  
##  Median :  76.00   Median : 22.00   Median :  40.0   Median :138  
##  Mean   : 104.29   Mean   : 31.19   Mean   :  61.1   Mean   :193  
##  3rd Qu.: 132.00   3rd Qu.: 39.00   3rd Qu.:  92.0   3rd Qu.:230  
##  Max.   : 613.00   Max.   :156.00   Max.   : 778.0   Max.   :912  
##  Total Expenses  
##  Min.   : 10.00  
##  1st Qu.: 33.00  
##  Median : 46.00  
##  Mean   : 54.06  
##  3rd Qu.: 65.00  
##  Max.   :190.00

Berdasarkan hasil syntax summary(), diperoleh gambaran umum mengenai kondisi keuangan Coffee Chain. Misalnya, pada variabel Marketing memiliki rentang nilai dari 0.00 hingga 156.00, yang menunjukkan variasi strategi anggaran di tiap wilayah. Selanjutnya, kuartil pertama sebesar 13.00, median sebesar 22.00, dan kuartil ketiga sebesar 39.00.

Analisis Korelasi Biaya Pemasaran dengan Keuntungan

Analisis dilakukan menggunakan uji korelasi Kendall’s-Tau untuk mengetahui korelasi antara biaya pemasaran dengan keuntungan yang diperoleh.

Ho: Tidak terdapat korelasi signifikan antara biaya pemasaran (Marketing) dengan keuntungan (Profit)

H1: Terdapat korelasi signifikan antara biaya pemasaran (Marketing) dengan keuntungan (Profit)

# Uji Korelasi Kendall
cor.test(coffeechain$Marketing, coffeechain$Profit, method = "kendall")
## 
##  Kendall's rank correlation tau
## 
## data:  coffeechain$Marketing and coffeechain$Profit
## z = 29.958, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
##      tau 
## 0.310664

Dari hasil yang didapatkan, diketahui bahwa nilai p-value < 2.2e-16 yang berarti < 0.05 sehingga H0 ditolak. Artinya, terdapat korelasi signifikan antara biaya pemasaran (Marketing) dengan keuntungan (Profit). Nilai koefisien korelasi sebesar 0.310664 menunjukkan adanya korelasi positif dengan kekuatan lemah.