Dataset ini berisi data transaksi penjualan makanan yang mencakup informasi region, kota, kategori produk, nama produk, quantity terjual, harga satuan, dan total penjualan.
Tujuan analisis ini adalah:
data <- read_excel("data/foodsales_sample.xlsx")
head(data, 10)
## # A tibble: 10 × 9
## ID Date Region City Category Product Qty UnitPrice
## <chr> <dttm> <chr> <chr> <chr> <chr> <dbl> <dbl>
## 1 ID07351 2022-01-01 00:00:00 East Boston Bars Carrot 33 1.77
## 2 ID07352 2022-01-04 00:00:00 East Boston Crackers Whole … 87 3.49
## 3 ID07353 2022-01-07 00:00:00 West Los Ange… Cookies Chocol… 58 1.87
## 4 ID07354 2022-01-10 00:00:00 East New York Cookies Chocol… 82 1.87
## 5 ID07355 2022-01-13 00:00:00 East Boston Cookies Arrowr… 38 2.18
## 6 ID07356 2022-01-16 00:00:00 East Boston Bars Carrot 54 1.77
## 7 ID07357 2022-01-19 00:00:00 East Boston Crackers Whole … 149 3.49
## 8 ID07358 2022-01-22 00:00:00 West Los Ange… Bars Carrot 51 1.77
## 9 ID07359 2022-01-25 00:00:00 East New York Bars Carrot 100 1.77
## 10 ID07360 2022-01-28 00:00:00 East New York Snacks Potato… 28 1.35
## # ℹ 1 more variable: TotalPrice <dbl>
glimpse(data)
## Rows: 244
## Columns: 9
## $ ID <chr> "ID07351", "ID07352", "ID07353", "ID07354", "ID07355", "ID0…
## $ Date <dttm> 2022-01-01, 2022-01-04, 2022-01-07, 2022-01-10, 2022-01-13…
## $ Region <chr> "East", "East", "West", "East", "East", "East", "East", "We…
## $ City <chr> "Boston", "Boston", "Los Angeles", "New York", "Boston", "B…
## $ Category <chr> "Bars", "Crackers", "Cookies", "Cookies", "Cookies", "Bars"…
## $ Product <chr> "Carrot", "Whole Wheat", "Chocolate Chip", "Chocolate Chip"…
## $ Qty <dbl> 33, 87, 58, 82, 38, 54, 149, 51, 100, 28, 36, 31, 28, 44, 2…
## $ UnitPrice <dbl> 1.77, 3.49, 1.87, 1.87, 2.18, 1.77, 3.49, 1.77, 1.77, 1.35,…
## $ TotalPrice <dbl> 58.41, 303.63, 108.46, 153.34, 82.84, 95.58, 520.01, 90.27,…
summary(data)
## ID Date Region
## Length:244 Min. :2022-01-01 00:00:00 Length:244
## Class :character 1st Qu.:2022-07-02 06:00:00 Class :character
## Mode :character Median :2022-12-31 12:00:00 Mode :character
## Mean :2022-12-31 01:58:01
## 3rd Qu.:2023-06-30 18:00:00
## Max. :2023-12-30 00:00:00
## City Category Product Qty
## Length:244 Length:244 Length:244 Min. : 20.00
## Class :character Class :character Class :character 1st Qu.: 31.00
## Mode :character Mode :character Mode :character Median : 47.00
## Mean : 63.29
## 3rd Qu.: 80.00
## Max. :306.00
## UnitPrice TotalPrice
## Min. :1.350 Min. : 33.60
## 1st Qu.:1.770 1st Qu.: 72.57
## Median :1.870 Median :102.75
## Mean :2.201 Mean :136.58
## 3rd Qu.:2.840 3rd Qu.:159.30
## Max. :3.490 Max. :817.92
summary_region<- data %>%
group_by(Region)%>%
summarise(Total_sales = sum(TotalPrice, na.rm = TRUE))%>%
arrange(desc(Total_sales))
ggplot(summary_region,aes(x= reorder(Region, Total_sales),y=Total_sales))+
geom_col(fill="#7C3AED")+geom_text(aes(label = comma(Total_sales)),
vjust = -0.2, size=3.5)+
scale_y_continuous(labels = comma)+
labs(
title = "Total penjualan per Region",
x = "Region",
y = "Total Sales ($)"
)+
theme_minimal()
Insight: Profit dapat dilihat dari region dengan total sales tertinggi, yaitu East dengan total sales $21,254. Menyusul West dengan $11,801. Dengan ini, konsumen pada East memiliki kemungkinan profit lebih tinggi di penjualan selanjutnya.
summary_product<-data %>%
group_by(Product)%>%
summarise(Total_Qty = sum(Qty, na.rm = TRUE))%>%
arrange(desc(Total_Qty))%>%
head(5)
ggplot(summary_product, aes(x = reorder(Product, -Total_Qty),y = Total_Qty))+
geom_col(fill = "#0EA5E9")+
geom_text(aes(label = comma(Total_Qty)),vjust=-0.2, size=3.5)+
labs(
title = "Top 5 product sales",
x = "Product",
y = "Total QTY"
)+ theme_minimal()
Insight: Terdapat 5 besar produk terlaris selama penjualan ke belakang, yaitu Carrot, Oatmeal Raisin, Arrowrot, Chocolate Chip, dan Bran. Dengan penjualan terbanyak pada Carrot sebanyak 4,187, kemudian Oatmeal Raisin 2,574, Arrowroot 2,445, Chocolate Chip 2,445, dan Bran 1,575.
summary_sales <- data %>%
mutate(Month = as.Date(cut(Date, "month"))) %>%
group_by(Month) %>%
summarise(
Total_sales = sum(TotalPrice, na.rm = TRUE),
.groups = "drop"
)
print(summary_sales)
## # A tibble: 24 × 2
## Month Total_sales
## <date> <dbl>
## 1 2022-01-01 1706.
## 2 2022-02-01 926.
## 3 2022-03-01 1648.
## 4 2022-04-01 1052.
## 5 2022-05-01 1393.
## 6 2022-06-01 2309.
## 7 2022-07-01 1263.
## 8 2022-08-01 1491.
## 9 2022-09-01 1524.
## 10 2022-10-01 1756.
## # ℹ 14 more rows
# Plot
ggplot(summary_sales, aes(x = Month, y = Total_sales)) +
geom_area(fill = "#10B981", alpha = 0.15) +
geom_line(color = "#10B981", linewidth = 1.2) +
geom_point(color = "#7C3AED", fill = "white",
shape = 21, size = 3, stroke = 1.5) +
scale_y_continuous(labels = comma) +
labs(
title = "Monthly Sales Trends",
x = "Month",
y = "Total Sales"
) +
theme_minimal()
Insight: Berikut merupakan trend penjualan sepanjang 2022-2023. Terdapat tekanan penjualan yang terjadi pada tahun 2023, dengan titik awal menurunnya pada Januari (~1.250) dan terendah pada Juli 2023 (~850), dengan demikian dapat diselidiki penyebabnya. Perbandingan yang signifikan dapat dilihat pada pertengahan tahun, yaitu Juni-2022 dan Juni-2023 dengan memiliki GAP ~1.150 atau penurunan sekitar 50%. Spike yang terjadi pada Juni 2022 dapat dicari tahu penyebabnya, apakah terdapat promo atau event yang dapat dijadikan strategi untuk direplikasi ke depannya.
summary_category <- data%>%
group_by(Category)%>%
summarise(Total_sales = sum(TotalPrice, na.rm = TRUE))%>%
mutate(
Persen = Total_sales / sum(Total_sales)*100,
Label = paste0(Category, "\n", round(Persen, 1), "%")
)
ggplot(summary_category, aes(x = 2, y = Total_sales, fill = Category))+
geom_col(color = "white", linewidth = 0.5)+
geom_text(aes(label = Label),
position = position_stack(vjust = 0.5),size = 3.5)+
coord_polar(theta = "y")+
xlim(0.5, 2.5)+
labs(title = "Sales per Category")+
theme_void()+
theme(legend.position = "none",
plot.background = element_rect(fill = "white", color = NA),
panel.background = element_rect(fill = "white", color = NA))
Insight: Distribusi penjualan category terbanyak jatuh pada Cookies. dengan dominasi 51% dan diikuti Bars 31%. Hal ini dapat dicari tahu produk dari category tersebut yang dapat diprioritaskan stok-nya untuk penjualan ke depan.
summary_city <- data %>%
group_by(City, Category) %>%
summarise(Total_Qty = sum(Qty, na.rm = TRUE), .groups = "drop")
ggplot(summary_city,
aes(x = reorder(City, -Total_Qty, sum),
y = Total_Qty,
fill = Category)) +
geom_bar(stat = "identity", position = "stack") +
labs(
title = "Sales Breakdown per City",
x = "City",
y = "Total QTY"
) +
theme_minimal()
Insight: Secara keseluruhan, Boston menjadi kota dengan total penjualan tertinggi (~5.400 QTY), diikuti New York (~4.050), Los Angeles (~3.850), dan San Diego (~2.050) sebagai yang terendah. Kategori Cookies mendominasi di seluruh kota sebagai kontributor terbesar, namun yang menarik adalah Boston memiliki porsi Crackers yang jauh lebih tinggi dibanding kota lain. Hal ini perlu diinvestigasi apakah terdapat faktor lokal seperti preferensi pasar atau pola distribusi yang mendorong kondisi tersebut. Sementara itu, Bars konsisten menjadi kontributor kedua di semua kota, mengindikasikan permintaan yang stabil lintas wilayah. Untuk optimasi stok ke depan, prioritas dapat diberikan pada Cookies dan Bars secara merata di semua kota, dengan perhatian khusus pada Crackers di Boston.
Kesimpulan: Berdasarkan analisis keseluruhan, Region East menjadi kontributor penjualan terbesar dengan total $21,254, dengan Cookies sebagai kategori yang paling mendominasi (51%) di seluruh kota. Produk terlaris secara quantity dipimpin oleh Carrot (4,187 QTY), sementara tren penjualan menunjukkan tekanan di 2023 dengan penurunan signifikan hingga 50% pada pertengahan tahun dibanding 2022. Ke depan, fokus pada replikasi strategi mid-2022 serta optimasi stok Cookies dan Bars di seluruh kota dapat menjadi prioritas untuk memulihkan dan meningkatkan performa penjualan.