dplyr, lubridate, ggplot2, scales, plotly, glue, kableExtra,rsconnect
# dplyr: untuk data wrangling/cleaning
library(dplyr)
heavy_equipment <- read.csv("data_input/heavy_equipment.csv")
Heavy Parts Analytics klik di sini
# your code
heavy_equipment %>%
head(5)
summary(data): Summary: Untuk menmpilkan rangkuman
statistik tiap kolom di data# your code
summary(heavy_equipment)
#> Row.ID Order.ID Customer.ID Customer.Name
#> Min. : 1 Min. : 18 Min. :1114487 Length:27976
#> 1st Qu.: 6995 1st Qu.: 5372 1st Qu.:1117096 Class :character
#> Median :14246 Median : 5372 Median :1119025 Mode :character
#> Mean :14171 Mean : 8374 Mean :1121144
#> 3rd Qu.:21239 3rd Qu.: 7429 3rd Qu.:1129027
#> Max. :28233 Max. :31968 Max. :1129027
#> Transaksi.ID Unit.Type Category Segment
#> Min. : 220301 Length:27976 Length:27976 Length:27976
#> 1st Qu.: 220602 Class :character Class :character Class :character
#> Median : 2111321115 Mode :character Mode :character Mode :character
#> Mean : 1659909822
#> 3rd Qu.: 2114521119
#> Max. :22063060002
#> Brand.ID Order.Date Ship.Date Cluster.Units
#> Length:27976 Length:27976 Length:27976 Length:27976
#> Class :character Class :character Class :character Class :character
#> Mode :character Mode :character Mode :character Mode :character
#>
#>
#>
#> Quantity Price.Per.Unit Sales Profit
#> Min. : 2.000 Min. : 1.00 Min. : 3.00 Min. :0.090
#> 1st Qu.: 3.000 1st Qu.: 4.00 1st Qu.: 15.00 1st Qu.:0.450
#> Median : 3.000 Median : 7.00 Median : 24.00 Median :0.720
#> Mean : 3.221 Mean :10.67 Mean : 33.64 Mean :1.009
#> 3rd Qu.: 3.000 3rd Qu.:21.00 3rd Qu.: 63.00 3rd Qu.:1.890
#> Max. :13.000 Max. :21.00 Max. :143.00 Max. :4.290
heavy_equipment %>%
group_by(Category) %>%
summarise(jumlah = n()) %>%
arrange(-jumlah) %>%
mutate(proporsi = jumlah/sum(jumlah))
Category Heavy Equipment yang paling banyak permintann adalah LOADER dengan proporsi 53,43% dari total penjualan heavy equipmrt yang ada.
DEEP ANALYSIS:
heavy_equipment %>%
group_by(Category, Segment) %>%
summarise(mean_profit = mean(Profit))
Segment CONSTRUCTION dari category EXCAVATOR menghasilkan rata-rata profit tertinggi, sedangkan Segment COMPACTOR dari category VIBRATORY ROLLERS menghasilkan rata-rata profit terendah.
3 Category yang menghasilkan total profit paling besar?
heavy_equipment %>%
group_by(Category, (Brand.ID)) %>%
summarise(sum_profit = sum(Profit)) %>%
top_n(1, wt = sum_profit) %>%
arrange(Category, sum_profit)
# base plot
plot(x = as.factor(heavy_equipment$Category))
library(ggplot2) # untuk plot statis
library(scales) # untuk atur skala/aestetik plot
library(glue) # untuk persiapan text di plot interaktif
library(plotly) # untuk plot interaktif
heavy_equipment %>%
group_by(Category) %>%
summarise(jumlah = n()) %>%
ggplot(aes(x = Category, y = jumlah)) +
geom_col(aes(fill = Category)) +
scale_fill_brewer(palette = "Dark2") +
labs(title = "Static Plot - Heavy Equipment",
x = NULL, y = "Number of Category") +
theme_minimal() +
theme(legend.position = "none")
# plot statis
plot_bar <- heavy_equipment %>%
group_by(Category) %>%
summarise(jumlah = n()) %>%
ggplot(aes(x = Category, y = jumlah,
text = glue("{Category}
Category: {jumlah}"))) +
geom_col(aes(fill = Category)) +
scale_fill_brewer(palette = "Dark2") +
labs(title = "Interactive Plot - Heavy Equipment",
x = NULL, y = "Number of Category") +
theme_minimal() +
theme(legend.position = "none")
# buat plot interactive
ggplotly(plot_bar, tooltip = "text")
Disclaimer: Data yang digunakan Hanya Ilustrasi saja, Untuk keperluan Explorasi Data!
TERIMAKASIH