library(knitr); opts_chunk$set(comment = NA)
library(dplyr)
library(ggplot2)
library(d3heatmap)
library(googleVis)
library(servr)
library(tidyr)
library(htmltools)1.Intro
以Olist角度分析賣家銷售行為,對賣家提出增加收益的策略建議
load("olist_final.RData")2.產品類別的特性比較
google motion chart
op <- options(gvis.plot.tag='chart')
options(op)
vistmp = gvisMotionChart(
visCate, "product_category_name_english", "dummy",
options=list(width=800, height=600, title="Product category"))
print(vistmp, file="M.html")
includeHTML("./M.html")Data: visCate • Chart ID: MotionChartID4e03cae791e • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
3.賣家所在地區(州)的特性比較
地理繪圖
includeHTML("./geo.html")Data: vis • Chart ID: GeoChartID33e0331467bb • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
4. 分群:以賣家銷售資料對賣家做分群 推測其產業類別
以賣家銷售類別比例 來計算距離作分群
以prop.table(margin=1) 計算每個賣家銷售產品的類別比例
mx = as.matrix(Segment[,2:72]) %>% prop.table(margin=1)
hc = dist(mx) %>% hclust(method="ward.D2")在反覆測試分群數目後,選擇20作為最終分群數
kg = cutree(hc, k=20)
cluster = as.data.frame(table(kg))
ggplot(cluster,aes(x=reorder(kg, -Freq), y = Freq)) +
geom_bar(stat="identity")+
labs(x="group number",y="seller number")mx = as.data.frame(mx)
mx$group = factor(cutree(hc, k=20))D = mx %>%
group_by(group) %>%
summarise_each(funs(mean))Warning: funs() is soft deprecated as of dplyr 0.8.0
please use list() instead
# Before:
funs(name = f(.)
# After:
list(name = ~f(.))
This warning is displayed once per session.
以熱圖呈現每群特性:同一群賣家的銷售產品類別比例
D[,2:72] %>%
as.matrix %>%
d3heatmap(col=colorRampPalette(c('black','darkblue','blue','green','yellow','orange','red'))(999),width = 800,height = 700)每個產業類別有領導賣家嗎?
以x軸為賣家總賣出的商品數量 , y軸為總收益 看出有哪幾群出現領導賣家
ggplot(Leader,aes(x=total_sold_num,y=total_rev))+
geom_point()+
facet_wrap(.~group)三個觀察點
- 觀察不同市場中,廠商銷售數及其收益的關係。
- 壟斷性競爭
- 不完全競爭市場
- 消費者偏好及品牌忠誠度
- 定價策略
- 產業集中度
- 用于衡量產業競爭性和壟斷性的最常用指標。
- 產業集中度高,代表這家企業具有較大的市場力
- 領導廠商定價
5. 照片數量與銷售量的關係
家具類商品的googlevis
includeHTML("Furniture.html")Data: vis_furniture • Chart ID: MotionChartID3bec48e59c8 • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
食物類產品
includeHTML("Food.html")Data: vis_food • Chart ID: MotionChartID3bec6598734b • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
寵物相關商品
includeHTML("Petshop.html")Data: vis_petshop • Chart ID: MotionChartID3bec60e56f2c • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
手錶禮品類
includeHTML("Watch.html")Data: vis_watch • Chart ID: MotionChartID3bec143e567c • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
香水
includeHTML("Perfumery.html")Data: vis_perfumery • Chart ID: MotionChartID3bec1baf3106 • googleVis-0.6.3
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy
R version 3.5.1 (2018-07-02) • Google Terms of Use • Documentation and Data Policy