Saya akan melakukan Exploratory Data Analysis terhadap data retail untuk mencari tahu pertanyaan bisnis meliputi :
# 1. Melihat jumlah segmentasi pasar secara keseluruhan berdasarkan data retail
# 2. Melihat jumlah quantity pembeli berdasarkan category
# 3. Melihat total sales berdasarkan sub.category
# 4. Melihat total profit yang perusahaan dapatkan
# Melakukan pengecekan data retail
retail <- read.csv("data_input/retail.csv")
head(retail)
## Row.ID Order.ID Order.Date Ship.Date Ship.Mode Customer.ID
## 1 1 CA-2016-152156 11/8/16 11/11/16 Second Class CG-12520
## 2 2 CA-2016-152156 11/8/16 11/11/16 Second Class CG-12520
## 3 3 CA-2016-138688 6/12/16 6/16/16 Second Class DV-13045
## 4 4 US-2015-108966 10/11/15 10/18/15 Standard Class SO-20335
## 5 5 US-2015-108966 10/11/15 10/18/15 Standard Class SO-20335
## 6 6 CA-2014-115812 6/9/14 6/14/14 Standard Class BH-11710
## Segment Product.ID Category Sub.Category
## 1 Consumer FUR-BO-10001798 Furniture Bookcases
## 2 Consumer FUR-CH-10000454 Furniture Chairs
## 3 Corporate OFF-LA-10000240 Office Supplies Labels
## 4 Consumer FUR-TA-10000577 Furniture Tables
## 5 Consumer OFF-ST-10000760 Office Supplies Storage
## 6 Consumer FUR-FU-10001487 Furniture Furnishings
## Product.Name Sales
## 1 Bush Somerset Collection Bookcase 261.9600
## 2 Hon Deluxe Fabric Upholstered Stacking Chairs, Rounded Back 731.9400
## 3 Self-Adhesive Address Labels for Typewriters by Universal 14.6200
## 4 Bretford CR4500 Series Slim Rectangular Table 957.5775
## 5 Eldon Fold 'N Roll Cart System 22.3680
## 6 Eldon Expressions Wood and Plastic Desk Accessories, Cherry Wood 48.8600
## Quantity Discount Profit
## 1 2 0.00 41.9136
## 2 3 0.00 219.5820
## 3 2 0.00 6.8714
## 4 5 0.45 -383.0310
## 5 2 0.20 2.5164
## 6 7 0.00 14.1694
# Melakukan pengecekan tipe data apakah sudah sesuai atau belum
glimpse(retail)
## Rows: 9,994
## Columns: 15
## $ Row.ID <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17…
## $ Order.ID <chr> "CA-2016-152156", "CA-2016-152156", "CA-2016-138688", "US…
## $ Order.Date <chr> "11/8/16", "11/8/16", "6/12/16", "10/11/15", "10/11/15", …
## $ Ship.Date <chr> "11/11/16", "11/11/16", "6/16/16", "10/18/15", "10/18/15"…
## $ Ship.Mode <chr> "Second Class", "Second Class", "Second Class", "Standard…
## $ Customer.ID <chr> "CG-12520", "CG-12520", "DV-13045", "SO-20335", "SO-20335…
## $ Segment <chr> "Consumer", "Consumer", "Corporate", "Consumer", "Consume…
## $ Product.ID <chr> "FUR-BO-10001798", "FUR-CH-10000454", "OFF-LA-10000240", …
## $ Category <chr> "Furniture", "Furniture", "Office Supplies", "Furniture",…
## $ Sub.Category <chr> "Bookcases", "Chairs", "Labels", "Tables", "Storage", "Fu…
## $ Product.Name <chr> "Bush Somerset Collection Bookcase", "Hon Deluxe Fabric U…
## $ Sales <dbl> 261.9600, 731.9400, 14.6200, 957.5775, 22.3680, 48.8600, …
## $ Quantity <int> 2, 3, 2, 5, 2, 7, 4, 6, 3, 5, 9, 4, 3, 3, 5, 3, 6, 2, 2, …
## $ Discount <dbl> 0.00, 0.00, 0.00, 0.45, 0.20, 0.00, 0.00, 0.20, 0.20, 0.0…
## $ Profit <dbl> 41.9136, 219.5820, 6.8714, -383.0310, 2.5164, 14.1694, 1.…
# Melakukan perubahan tipe data terhadap kolom yang sekiranya masih belum sesuai terhadap datanya
retail <- retail %>%
mutate(Ship.Mode = as.factor(Ship.Mode),
Segment = as.factor(Segment),
Category = as.factor(Category),
Sub.Category = as.factor(Sub.Category),
Order.Date = as.Date(Order.Date, format = "%d/%m/%y"),
Ship.Date = as.Date(Ship.Date, format = "%d/%m/%y")) %>%
select(-Row.ID) #Menghapus kolom yang tidak diperlukan menggunakan select
glimpse(retail)
## Rows: 9,994
## Columns: 14
## $ Order.ID <chr> "CA-2016-152156", "CA-2016-152156", "CA-2016-138688", "US…
## $ Order.Date <date> 2016-08-11, 2016-08-11, 2016-12-06, 2015-11-10, 2015-11-…
## $ Ship.Date <date> 2016-11-11, 2016-11-11, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ Ship.Mode <fct> Second Class, Second Class, Second Class, Standard Class,…
## $ Customer.ID <chr> "CG-12520", "CG-12520", "DV-13045", "SO-20335", "SO-20335…
## $ Segment <fct> Consumer, Consumer, Corporate, Consumer, Consumer, Consum…
## $ Product.ID <chr> "FUR-BO-10001798", "FUR-CH-10000454", "OFF-LA-10000240", …
## $ Category <fct> Furniture, Furniture, Office Supplies, Furniture, Office …
## $ Sub.Category <fct> Bookcases, Chairs, Labels, Tables, Storage, Furnishings, …
## $ Product.Name <chr> "Bush Somerset Collection Bookcase", "Hon Deluxe Fabric U…
## $ Sales <dbl> 261.9600, 731.9400, 14.6200, 957.5775, 22.3680, 48.8600, …
## $ Quantity <int> 2, 3, 2, 5, 2, 7, 4, 6, 3, 5, 9, 4, 3, 3, 5, 3, 6, 2, 2, …
## $ Discount <dbl> 0.00, 0.00, 0.00, 0.45, 0.20, 0.00, 0.00, 0.20, 0.20, 0.0…
## $ Profit <dbl> 41.9136, 219.5820, 6.8714, -383.0310, 2.5164, 14.1694, 1.…
colSums(is.na(retail))
## Order.ID Order.Date Ship.Date Ship.Mode Customer.ID Segment
## 0 5952 6096 0 0 0
## Product.ID Category Sub.Category Product.Name Sales Quantity
## 0 0 0 0 0 0
## Discount Profit
## 0 0
Insight : Membiarkan date tetap NA dikarenakan hampir > 75% kolom order.date dan ship.date tidak memiliki tanggalnya, karena saya tidak bisa sembarangan mencantumkan tanggal dari suatu pemesanan barang dalam skala besar, jadi saya kosongkan saja karena disini kita lebih fokus terhadap data hasil dari business case.
retail %>%
group_by(Segment)%>%
count(Segment, name = "Count")
## # A tibble: 3 × 2
## # Groups: Segment [3]
## Segment Count
## <fct> <int>
## 1 Consumer 5191
## 2 Corporate 3020
## 3 Home Office 1783
Insight : Consumer merupakan segmentasi terbanyak yang membeli barang pada retail yakni dengan total sebanyak 5191
retail %>%
group_by(Category) %>%
summarise(Qty = sum(Quantity)) %>%
arrange(desc(Qty))
## # A tibble: 3 × 2
## Category Qty
## <fct> <int>
## 1 Office Supplies 22906
## 2 Furniture 8028
## 3 Technology 6939
Insight : Office supplies merupakan kategori barang tertinggi dan banyak diminati oleh konsumen yakni sebanyak 22906 produk yang terjual. Berbanding jauh dengan 2 kategori produk lainnya yaitu furniture yang hanya dapat menjual produk sebanyak 8028 dan kategori teknologi yang hanya dapat menjual sebanyak 6939 produk.
retail %>%
group_by(Sub.Category) %>%
summarise(Total_sales = sum(Sales)) %>%
arrange(desc(Total_sales))
## # A tibble: 17 × 2
## Sub.Category Total_sales
## <fct> <dbl>
## 1 Phones 330007.
## 2 Chairs 328449.
## 3 Storage 223844.
## 4 Tables 206966.
## 5 Binders 203413.
## 6 Machines 189239.
## 7 Accessories 167380.
## 8 Copiers 149528.
## 9 Bookcases 114880.
## 10 Appliances 107532.
## 11 Furnishings 91705.
## 12 Paper 78479.
## 13 Supplies 46674.
## 14 Art 27119.
## 15 Envelopes 16476.
## 16 Labels 12486.
## 17 Fasteners 3024.
Insight : - Phones merupakan produk yang memiliki total revenue tertinggi terhadap perusahaan dengan total penjualan sebanyak 330007.05. - Produk 5 terbesar dalam total revenue sales ditempati kategori produk Office Supplies
retail %>%
group_by(Category) %>%
summarise(pendapatan = sum(Profit)) %>%
bind_rows(
retail %>%
summarise(pendapatan = sum(Profit)) %>%
mutate(Category = "Total")
) %>%
arrange(pendapatan)
## # A tibble: 4 × 2
## Category pendapatan
## <chr> <dbl>
## 1 Furniture 18451.
## 2 Office Supplies 122491.
## 3 Technology 145455.
## 4 Total 286397.
Insight : Total profit yang perusahaan dapatkan dari keseluruhan kategori produk yakni mendapatkan sebanyak 286397.02
Consumer merupakan customer dengan jumlah terbanyak dalam pembelian produk dalam perusahaan. Dengan rata2 kategori produk yang terjual yakni ada pada Office supplies dan technology yang memungkinkan rata2 konsumen memerlukannya untuk suatu kebutuhan baik dikantornya maupun dirumah atau kebutuhan sehari-hari.