本分析的目的是基于跨国公司订单数据开展市场分析,对公司产品销售、市场分布、产品利润情况进行推理判断,对相关重点问题做出解答与建议。
1.公司不同区域的产品销售情况怎样?哪些区域表现较好,哪些区域存在问题?
2.公司目前的市场分布呈现怎样的特点?产品销售的全球市场构成如何?
3.公司产品利润情况有何特点?产品利润与市场、区域呈现怎样的关系?
4.订单数据揭示的公司市场业绩整体表现和不同区域表现如何?有哪些需要改进之处?
rm(list=ls())
setwd("C:/Users/Joker/Desktop")# 设置数据集和分析结果所在工作目录
begin<- Sys.time()#R_basefunction中的函数,记录当前系统运行时间点
options(warn=-1) #消除警告信息
library(readxl)
library(tidyverse)
library(ggplot2)
library(dplyr)
library(bbplot)
library(tibble)
library(gganimate)
library(forecast)
library(maptools)
library(sp)
library(classInt)
library(rworldmap)
library(RColorBrewer)
library(countrycode)
library(broom)
library(tseries)
data <- read_excel("global-superstore.xlsx","订单")%>%
mutate(year = lubridate::year(purchasedate))#将purchase另存为year列
#data <- data[,c(1:2,4,6:8)]#取data数据框中的12列,4列,678列
# %in% 判断前面一个向量内的元素是否在后面一个向量中,返回逻辑判断布尔值
#data <- data[,-2] # 剔除第2列
#head <- data[sample(1:nrow(data),5), ]
#head <- head[order(head$SNo),]
head## function (x, ...)
## UseMethod("head")
## <bytecode: 0x0000000014553678>
## <environment: namespace:utils>
#Prepare data数据准备
totalsale<-as.numeric(data %>%
summarise(totalsales = sum(sales)))
pie<-data %>%
group_by(market)%>%
summarise(regionalsales = sum(sales))%>%
mutate(Percentage = regionalsales/totalsale*100,3)
#设置标签
percent<-rev(pie$Percentage) #颠倒标签在y轴上的顺序
percent<- round(percent,1)
#Make plot绘图
ggplot(pie,aes(x="",y=Percentage,fill=market)) +
geom_bar(stat = "identity",color="white") +
scale_fill_brewer(palette="GnBu")+
coord_polar(theta = "y") +
theme(axis.text.x = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank()) +
geom_text(aes(y= cumsum(percent)-percent/2, x= 1),label=percent)#Prepare data数据准备
orders1<-data%>%
group_by(market)%>%
summarise(totalsales = sum(sales))
#Make plot绘图
p1 <- ggplot(orders1, aes(x = market, y = totalsales,fill=(totalsales))) +
geom_col()+
scale_fill_distiller(palette="Blues",direction =1)+
theme_minimal()+
theme(
panel.grid = element_blank(),
panel.grid.major.y=element_line(color = "white"),
panel.ontop=TRUE
)+#增加标题,坐标轴标签
labs(x = "市场分布", y = "地区总销售量"
,title="不同区域整体销售情况"
,subtitle="EMEA为欧洲、中东、非洲三地区的合称")+
#theme_grey(base_family = "STKaiti")+#调整字体大小、颜色
#theme(plot.title = ggplot2::element_text(size=16,face="bold",color = "#222222"),
#plot.subtitle=ggplot2::element_text(size=10),
#axis.text = ggplot2::element_text(size=14))
geom_label(aes(x = market, y = totalsales,fill=(totalsales),label = round(totalsales, 0)),#添加数据标签
hjust = 0.5,
vjust = 0.6,
colour = "black",
fill = NA,
label.size = NA,
family="Helvetica",
size = 4)
#加入动画效果
#example1<-p1+transition_states(totalsales,wrap = FALSE)+shadow_mark()
#animate(example1,duration=50)#调整图像运动快慢
#example1
#由于上述无法直接输出,此处导入图片进行结果呈现我们对2011-2014四年跨国公司销售量按照市场分组加总,得到如上图像; 由图中可以看出,
1.从四年市场总销售量看,亚太市场总销售额最高,加拿大市场总销售额最低;
2.EMEA(即欧洲、中东、非洲三地区加总)市场与非洲市场销售额接近,四年总销售额相差约2万;
orders<-data%>%
group_by(country) %>%
summarise(totalsales = sum(sales),
totalprofit = sum(profit)) %>%
#计算销售利润率
#mutate(p2s_rario = totalprofit / (totalsales-totalprofit)) %>%
{.->>ordersmapdata}
ordersmapdata <- ordersmapdata[,c(1,2)]
#将中文国家名转换为ISO3标准
hk <- c('香港','HKG')##补充匹配,下同
tw <- c('中国台湾','TWN')
es <- c('俄塞俄比亚','ETH')
gg <- c('刚果共和国','COG')
gd <- c('刚果民主共和国','COD')
jk <- c('捷克共和国','CZE')
custom_dict <- data.frame(chinese = countrycode::codelist$cldr.name.zh,
iso3c = countrycode::codelist$iso3c,
stringsAsFactors = FALSE)%>%
rbind(hk,tw,es,gg,gd,jk)%>%
{.->>custom_dict}%>%
countrycode(ordersmapdata$country, origin = 'chinese',
destination = 'iso3c',custom_dict = .) %>%
cbind(ordersmapdata$totalsales) %>%
as.data.frame() %>%
{. ->> mapdata}
colnames(mapdata) <- c('ISO3c','totalsales')
mapdata$ISO3c <- as.character(mapdata$ISO3c)
mapdata$totalsales <- as.numeric(as.character(mapdata$totalsales))
#查看缺失值
#sum(is.na(mapdata)) #无缺失值
#将数据加入地图
ordersmap <- joinCountryData2Map(mapdata,joinCode = 'ISO3',
nameJoinColumn = 'ISO3c')
classInt <- classIntervals( ordersmap[["totalsales"]], n=5,
style="jenks")
catMethod = classInt[["brks"]]
#colourPalette <- brewer.pal(5,'RdPu')
colourPalette <- brewer.pal(5,'PuOr')
mapPDF <- mapCountryData(ordersmap,nameColumnToPlot = 'totalsales'
, mapTitle = "全球销售额分布地图"
, addLegend = F, catMethod = catMethod
, colourPalette = colourPalette)
do.call( addMapLegend, c( mapPDF, legendLabels="all", legendWidth=0.5,
legendIntervals="data", legendMar = 2 ))上图是以各国销售额为基准作出的热力图,可以看出:
1.颜色较为深的有美国地区,亚太地区,澳洲等,在非洲等地销售额较少。
2.整体来看销售分布较为均衡,非洲欧洲地区销售有待加强,还可以进一步拓宽市场。
backs <- read_excel("global-superstore.xlsx",sheet = "退回")
orders <- read_excel("global-superstore.xlsx",sheet = "订单")
orders_count_market <- orders %>% select(market) %>% group_by(market) %>%
summarise(count=n())
backs_count <- backs %>% select(已退回,market) %>% group_by(market) %>% summarise(count=n()) %>%
mutate(ratio=count/c(10294,9994,10000,11002))
ggplot(backs_count ,aes(x=market,y=ratio,fill=market)) +
geom_bar(stat="identity",position="dodge") +
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
geom_text(aes(y=ratio+0.001,label=round(ratio,4)))+
bbc_style()+
labs(title = "2011-2014年各地区退回率",y="退回率",x="市场")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8)) 1.公司的退货主要发生在拉丁美洲、美国、欧盟及亚太地区四个区域,退回率相差不大,均接近3%。其中美国地区退回率最高,而亚太地区退回路最低。
2.公司在非洲、加拿大及EMEA三个市场均无退货发生,情况可观。
3.公司应分析商品退回的原因,采取适当策略,尽可能降低退回率。
#Prepare data数据准备
orders2<-data%>%
filter(year == 2011 | year == 2014) %>%
select(market, year, sales) %>%
group_by(market,year)%>%
summarise(sales=sum(sales))%>%
spread(year, sales) %>%
mutate(gap = `2011` - `2014`) %>%
arrange(desc(gap)) %>%
head(5) %>%
gather(key = year,
value = sales,
-market,
-gap)
#Make plot绘图
example3 <- ggplot(orders2,
aes(x = market,
y = sales,
fill = as.factor(year))) +
geom_bar(stat="identity", position="dodge") +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
bbc_style() +
scale_fill_brewer(palette="PuBu")+
#scale_fill_manual(values = c("#1380A1", "#FAAB18")) +
labs(title="不同区域市场销售变动情况分析",
subtitle = "市场销售上升情况, 2011-2014")+
geom_text(#添加数据标签
aes(label = sales, sales = sales + 0.09),
position = position_dodge(0.9),
vjust = 0
)
#geom_text(aes(label = sales), position = position_dodge(0.9))
example3我们进一步对2011年和2014年数据进行对比分析,得到图像如上; 图中可以看到,2011-2014年
1.各个市场销售额均有所增长;其中拉丁美洲增长量最大,加拿大增长量最小;
2.EAMA市场与非洲市场增长额趋同;
3.在此基础上可以认为拉丁美洲与美国销售商品情况占据市场主要利润来源,而加拿大市场盈利不足,存在一定问题;
#Prepare data数据准备
orders3<-data%>%
separate(col =orderid,
into =c('center','year','product'),
sep ='-')
#Make plot绘图
P2<-orders3%>%
mutate(year=lubridate::year(purchasedate))%>%
group_by(market,year)%>%
summarise(totalsales=sum(sales))%>%
mutate(ratio=(totalsales-lag(totalsales))/lag(totalsales))%>%
ggplot(.,aes(x=year,y=ratio,colour=factor(market)))+geom_line(size=1.3)+
bbc_style()+labs(title="市场分布",subtitle="销售额同比增长")+
scale_color_brewer(palette = "PuBu")
P2我们对2011-2014四年跨国公司销售量按照市场分组加总,之后求得不同市场销售额的同比增长率,得到如上图像;
由图中可以看出,
1.从三年的市场销售同比增长率来看,整体上各市场的销售额同比增长为正,即各市场销售额整体稳步上升,只有拉丁美洲在2012年同比增长率为负;
2.局部来看,加拿大市场在2012年销售额同比增长率达到最高,接近100%,也就是翻倍的程度,市场客观,但其之后两年的增长率降低至20%左右,相对稳定;
3.拉丁美洲、美国、亚太地区和非洲四个地区的同比增长率变化情况相似,均为先上升后下降的趋势,2013年的同比增长率为达到最高;
4.2014年各个市场销售额同比增长率普遍较低,均低于50%,市场呈现缓慢增长的态势。
#Prepare data数据准备
library(ggplot2)
library(bbplot)
library(readxl)
orders<-read_excel("global-superstore.xlsx","订单")
y_axis_formatter=function(x){
return(paste(x/1000,'K',sep=""))
}
#Make plot绘图
p <- ggplot(orders, aes(x = segment, y = quantity),plot(cex.axis=0.5)) +
geom_bar(stat='identity',aes(fill = type)) +
facet_grid(type~market) +
scale_y_continuous(labels = y_axis_formatter) +
xlab("细分市场") + ylab("数量") + coord_flip() +
bbc_style()+
scale_fill_brewer(palette = "PuBu")+
labs(title="各市场的细分市场的销售数量")+
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())
p我们对各个市场不同类别的细分市场的销售数量进行分析,得到图像如上
图中可以看到,在各个市场中:
1.拉丁美洲、美国、欧盟和亚太地区的购买力较强,产品的销售情况较好,而EMEA、非洲和加拿大的销售情况较差
2.各个市场的产品购买数量均为办公用品>家具>技术,购买人群均为消费者>公司>家庭办公室
3.在购买不同产品的人群中,消费者所占比例最高
#Prepare data数据准备
orders5<-data%>%
group_by(subtype)%>%
summarise(totalquantity = sum(quantity))%>%
top_n(5,totalquantity)%>%
arrange(desc(totalquantity))%>%#求出不同市场销售量最高的五种产品
ggplot(orders,mapping=aes(x = subtype,y = totalquantity))+
geom_bar(stat='identity',aes(fill = subtype))+
bbc_style()+theme(legend.position="top")+scale_fill_brewer(palette="PuBu")+
labs(title="List of Advantage Products",subtitle="Five top products sold,2011-2014")+geom_label(aes(x = subtype, y = totalquantity,fill=(totalquantity),label = round(totalquantity, 0)),#添加数据标签
hjust = 0.5,
vjust = 0.6,
colour = "black",
fill = NA,
label.size = NA,
family="Helvetica",
size = 4)
orders5此处我们求出2011-2014四年跨国公司销售量最高的五种优势产品,得到图像如图所示;
由图中可以看出前五种优势产品分别是:装订机、纸张、椅子、美术用品、存储用品;
其中装订机销售量最高,椅子销售量最低,和纸张销售量相差不大;
#导入数据
orders_filter<-filter(data,(subtype=="装订机"|subtype=="纸张"|subtype=="椅子"|subtype=="美术"|subtype=="存储"))%>%
group_by(market,subtype)%>%
summarise(totalquantity = sum(quantity))%>%
select(market,subtype,totalquantity)
#绘图
p4<-ggplot(orders_filter, mapping = aes(x=market, y=totalquantity,fill=subtype)) +
geom_bar(stat = 'identity',aes(fill = subtype)) +
bbc_style()+
scale_fill_brewer(palette="PuBu")+
labs(title="Advantage Products,2011-2014",subtitle="Products sold in Different Countries")
p4+coord_polar()五种优势产品分地区来看,
在七个国际市场中,加拿大五样产品销售量都非常低,说明加拿大并非主流市场。同样,在EMEA和非洲市场同样销售量很低,仅次于加拿大,这两个市场也并非优势市场。
而在拉丁美洲、美国、欧洲、亚太地区四个市场,五种产品销售量均均高于之前三个非优势市场;其中“装订机”和“纸张”在美国销售量最高,其需求量最大;而美术和存储用具在欧洲市场销售量最高。
在亚太地区和拉丁美洲,五种优势产品的销售量较为均匀,对不同产品的不同需求极为相似,总体上来说,美国和欧盟表现出对某些产品有较大偏爱。
#Prepare data数据准备
groupbar<-data %>% group_by(segment,type) %>% summarise(totalsales = sum(sales))
#Make plot绘图
ggplot(groupbar,
mapping = aes(x = segment, y = totalsales, fill = as.factor(type))) +
geom_bar(stat = 'identity', position="dodge"
#fill="lightblue",colour="black"
) +
xlab('消费群体') + ylab('总销售额') +
bbc_style()+
geom_hline(yintercept = 0, size = 1, colour="#333333")+
#scale_fill_brewer(palette="GnBu")+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","skyblue3"))+
labs(title="市场分布",
subtitle = "不同产品消费群体分布")图中可以看到,不同产品的消费者群体分布相似,
消费者用户是主力军,公司用户其次,家庭办公室消费最少,消费者用户是公司用户消费量的2倍左右,是家庭办公室的4倍左右。
再对不同消费者群体购买的产品分布进行分析,
不同的用户种类购买产品类型分布也相似,技术类型产品消费量最多,其次是家具,最少是办公用品类,但总体来看差异不大,不同消费群体在三种产品消费上均较为平均。
orders <- read_excel("global-superstore.xlsx",sheet = "订单")
#str(orders)
#拆分年月日三列
orders <- orders %>% separate(col=purchasedate,into = c('year','month','date'),sep = '-')#年度产品的利润分布
profit_all_year <- orders %>% select("year","profit") %>%group_by(year) %>% summarise(sum_year=sum(profit))
#年度利润折线图
p1<-ggplot(profit_all_year, aes(x=year, y=sum_year,group=1)) +
geom_line(colour= "#2166AC",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#2166AC")+
geom_text(aes(y=sum_year+35000,label=round(sum_year,2)))+
bbc_style()+
labs(title = "2011-2014年利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))
p1profit_all_year <- profit_all_year %>% mutate(ratio = (sum_year-lag(sum_year))/lag(sum_year))
ggplot(filter(profit_all_year,year!=2011), aes(x=year, y=ratio,group=1)) +
geom_line(colour= "#2166AC",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#2166AC")+
ylim(0.15,0.4)+
geom_text(aes(y=ratio+0.02,label=round(ratio,3)))+
bbc_style()+
labs(title = "2011-2014年年利润增长率",y="增长率/%",x="年度")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5))从上方两张图中可以看到,2011至2014年的年利润呈逐步上升的趋势,由2011年至2014年年利润提升了2倍。2011至2014年的年利润增长率都大于20%,其中2013年增长率最大,为32.37%。因此,该跨国公司每年经营状况逐渐变好。
profit_all_month <- orders %>% select("year",'month',"profit") %>%group_by(year,month) %>% summarise(sum_month=sum(profit))
profit_all_season <- profit_all_month %>% spread(month,sum_month)%>%
transmute(一季=`01`+`02`+`03`,二季=`04`+`05`+`06`,
三季=`07`+`08`+`09`,四季=`10`+`11`+`12`)%>%
gather(season,sum_season,一季:四季)%>%
arrange(year)
#2011-2014季度折线图
profit_all_season <- profit_all_season %>% unite(year_season,year,season)
ggplot(profit_all_season, aes(x=factor(year_season,levels = c('2011_一季','2011_二季','2011_三季','2011_四季','2012_一季','2012_二季','2012_三季','2012_四季','2013_一季','2013_二季','2013_三季','2013_四季','2014_一季','2014_二季','2014_三季','2014_四季')), y=sum_season,group=1)) +
geom_line(colour= "#2166AC",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#2166AC")+
geom_text(aes(y=sum_season+15000,label=round(sum_season)))+
bbc_style()+
labs(title = "2011-2014年各季度利润分布",y="利润",x="季度")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5))profit_all_season <- profit_all_season %>% mutate(ratio = (sum_season-lag(sum_season))/lag(sum_season))
ggplot(filter(profit_all_season,year_season!='2011_一季'), aes(x=factor(year_season,levels = c('2011_一季','2011_二季','2011_三季','2011_四季','2012_一季','2012_二季','2012_三季','2012_四季','2013_一季','2013_二季','2013_三季','2013_四季','2014_一季','2014_二季','2014_三季','2014_四季')), y=ratio,group=1)) +
geom_line(colour= "#2166AC",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#2166AC")+
#geom_text(aes(y=sum_season+20000,label=round(sum_season)))+
bbc_style()+
labs(title = "2011-2014年季度利润增长率",y="增长率/%",x="季度")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5))由上图1可以得到,2011至2014年的季度利润呈现出波动上升的趋势,由2011年第一季度到2014年第四季度,季度利润提升了近5倍。同时可以看到,每年的第一季度利润较低,为销售淡季,第四季度利润在一年中最高,为销售旺季,此时消费者购买需求和欲望较为强烈。
由上图2可以得到,2011至2014年的季度利润增长率波动较大,每年的第一季度都会出现较大的负增长率,其他季度都为正增长率.
profit_all_month <- orders %>% select("year",'month',"profit") %>%group_by(year,month) %>% summarise(sum_month=sum(profit))
orders %>% unite(purchasedate,year,month,date,sep = '-') %>%
mutate(year=lubridate::year(purchasedate),month=lubridate::month(purchasedate))%>%
group_by(month,year)%>%summarise(sum=sum(profit))%>%
ggplot(., aes(x=month, y=sum,group=1,colour=factor(year),group=factor(year))) +
geom_line(size=1)+
scale_x_continuous(breaks = 1:12)+facet_grid(.~year)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#scale_fill_brewer(palette = 'GnBu')+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年月度利润分布",y="利润",x="月度")+
theme(plot.title = element_text(size=20,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))#综合月度利润折线图
profit_all_month <- profit_all_month %>% unite(year_month,year,month,sep = '-')
ggplot(profit_all_month, aes(x=year_month, y=sum_month,group=1)) +
geom_line(colour= "#2166AC",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20,colour="#2166AC")+
#geom_text(aes(y=sum_season+15000,label=round(sum_season)))+
bbc_style()+
labs(title = "2011-2014年各月度利润分布",y="利润",x="月度")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5))从上面2张图可见,2011至2014年每年的月利润都呈波动上升趋势,并且总体也呈波动上升趋势。可以看到,每年的5-6月会出现一个销售旺季,在7月利润会大幅下跌,随后在9月又会出现一个销售旺季,因此,该公司可以在淡旺季时采取不同的销售策略。
1.该公司每年的盈利情况都有所提升,整体态势良好。
2.该公司存在销售旺季和销售淡季,每年第一季度为淡季,第四季度为旺季。更具体的,每年的5-6月会出现小旺季,9月-10月出现大旺季,而1月和7月会出现淡季。因此,公司需要针对销售淡季和旺季分别制定销售策略。
profit_type <- orders %>% select(type,profit) %>% group_by(type) %>%
summarise(sum=sum(profit),count=n())%>%
mutate(mean = sum/count)
ggplot(profit_type, aes(x=type, y=sum,fill=factor(type))) + geom_bar(stat="identity",position="identity")+#,fill="#1380A1"
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette="PuBu")+
#geom_col(aes(fill=type), position="dodge")
geom_text(aes(label=round(sum,2), y=sum+0.12), position=position_dodge(0.9), vjust=0)+
bbc_style()+
labs(title = "2011-2014年各类产品总利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'none')由上图可见,2011至2014年,技术类产品带来的利润最大,办公用品带来的利润其次,家具带来的利润最小,仅有办公用品的一半.
profit_type_year <- orders %>% select(year,type,profit) %>% group_by(year, type) %>%
summarise(sum = sum(profit))
ggplot(profit_type_year,aes(x=type,y=sum,fill=type)) + geom_bar(stat="identity") +
facet_grid(.~year)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
scale_fill_brewer(palette="PuBu")+
#geom_col(aes(fill=type), position="dodge")
#geom_text(aes(label=sum, y=sum+0.05), position=position_dodge(0.9), vjust=0)+
bbc_style()+
labs(title = "2011-2014年各年度各类产品利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5),
legend.position = 'none')ggplot(profit_type_year, aes(x=year,y=sum,colour=factor(type),group=factor(type))) +
geom_line(size=1)+
facet_grid(.~type)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#scale_fill_brewer(palette="PuBu")+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年各年各类产品利润",y="利润",x="年度")+
theme(plot.title = element_text(size=18,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))由上方两张图中可以看出,2011至2014年每年的技术产品带来的利润占比最大,并且增长趋势最快,办公用品其次,增长趋势较快,家具占比最小,且增长缓慢,2011至2012年及2013至2014年几乎没有增长。
profit_subtype_year <- orders %>% select(year,type,subtype,profit) %>%
group_by(year,type,subtype) %>% summarise(sum=sum(profit))
#画出各个年份各个子类别的获利情况 bar
ggplot(profit_subtype_year,aes(x=type,y=sum,fill=subtype)) +
geom_bar(stat="identity",position="dodge") + facet_grid(year~.)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
#scale_fill_brewer(palette=c("Pastel1","Pastel2"))+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE")))
bbc_style()+
labs(title = "2011-2014年各年各子产品利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 6))由上图可见,2011至2014年各个子类型产品除了桌子外,其所带来的利润都有所上升,其中办公用品中以电器为最,技术类产品中以复印机为最,家具类产品中以书架为最,而桌子带来的亏损却在逐年增大。
profit_subtype <- orders %>% select(type,subtype,profit) %>% group_by(type,subtype)%>%
summarise(sum=sum(profit),count=n())%>%
mutate(mean=sum/count)
ggplot(filter(profit_subtype,type=='办公用品'),aes(x=type, y=sum, fill=subtype)) +
geom_bar(stat="identity",position="fill") + coord_polar("y",start=0)+
scale_fill_brewer(palette="PuBu")+
#geom_hline(yintercept = 0,size=1, colour="#333333")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE")))
bbc_style()+
labs(title = "2011-2014年办公用品总利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(filter(profit_subtype_year,type=="办公用品"), aes(x=year,y=sum,colour=factor(subtype),group=factor(subtype))) +
geom_line(size=1)+
facet_grid(.~subtype)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年各年办公用品利润变化情况",y="利润",x="年度")+
theme(plot.title = element_text(size=18,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))上两张图中显示,2011至2014年办公用品类别中,电器类产品带来的利润最大,约为25%,存储类产品其次,系固件类产品和标签类产品带来的利润较小。同时,电器类产品和存储类产品增长十分迅速,而标签类产品、系固件类产品,信封类产品及用品类产品增长十分缓慢。
ggplot(filter(profit_subtype,type=='技术'),aes(x=type, y=sum, fill=subtype)) +
geom_bar(stat="identity",position="fill") + coord_polar("y",start=0)+
scale_fill_brewer(palette="PuBu")+
#geom_hline(yintercept = 0,size=1, colour="#333333")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE")))
bbc_style()+
labs(title = "2011-2014年技术利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(filter(profit_subtype_year,type=="技术"), aes(x=year,y=sum,colour=factor(subtype),group=factor(subtype))) +
geom_line(size=1)+
facet_grid(.~subtype)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年各年技术利润变化情况",y="利润",x="年度")+
theme(plot.title = element_text(size=18,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))上两张图中显示,2011至2014年技术类产品中,复印机类产品带来的利润最大,约为40%,电话类产品其次,设备类产品带来的利润最小。同时,复印机类产品增长十分迅速,而设备类产品增长缓慢,电话类产品波动较大。
ggplot(filter(profit_subtype,type=='家具'),aes(x=type, y=sum, fill=subtype)) +
geom_bar(stat="identity",position="dodge") +
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette="PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE")))
bbc_style()+
labs(title = "2011-2014年家具利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(filter(profit_subtype_year,type=="家具"), aes(x=year,y=sum,colour=factor(subtype),group=factor(subtype))) +
geom_line(size=1)+
facet_grid(.~subtype)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年各年家具利润变化情况",y="利润",x="年度")+
theme(plot.title = element_text(size=18,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))上两张图中显示,2011至2014年家具类别产品中,书架类产品带来的利润最大,椅子类产品其次,但桌子类产品带来的利润为负,呈亏损状态。同时,书架类产品增长速度较快,而桌子类产品每年都呈亏损状态,甚至亏损越来越大。
#####小结与建议
1.该公司三类产品中带来利润最多的是技术类产品,强调了技术的重要性。
2.四年中三类产品带来的利润逐年上升,其中办公用品和技术类产品上升较快,家居类产品上升较慢。
3.在子类型中,电器、复印机和书架分别是三类产品带来利润最多的,同时也是增长最快的,需要重点生产销售,而桌子却逐年亏损,需要及时抛弃或采取相应销售策略。
4.该公司需要对于带来利润大,且增长快的子类型产品予以重点销售对象,对于带来利润小,增长慢甚至负增长的产品及时抛弃或想办法降低成本。
orders %>% group_by(country) %>%
summarise(totalsales = sum(sales),
totalprofit = sum(profit)) %>%
#计算销售利润率
#mutate(p2s_rario = totalprofit / (totalsales-totalprofit)) %>%
{.->>ordersmapdata}
ordersmapdata <- ordersmapdata[,c(1,3)]
#将中文国家名转换为ISO3标准
hk <- c('香港','HKG')##补充匹配,下同
tw <- c('中国台湾','TWN')
es <- c('俄塞俄比亚','ETH')
gg <- c('刚果共和国','COG')
gd <- c('刚果民主共和国','COD')
jk <- c('捷克共和国','CZE')
custom_dict <- data.frame(chinese = countrycode::codelist$cldr.name.zh,
iso3c = countrycode::codelist$iso3c,
stringsAsFactors = FALSE)%>%
rbind(hk,tw,es,gg,gd,jk)%>%
{.->>custom_dict}%>%
countrycode(ordersmapdata$country, origin = 'chinese',
destination = 'iso3c',custom_dict = .) %>%
cbind(ordersmapdata$totalprofit) %>%
as.data.frame() %>%
{. ->> mapdata}
colnames(mapdata) <- c('ISO3c','totalprofit')
mapdata$ISO3c <- as.character(mapdata$ISO3c)
mapdata$totalprofit <- as.numeric(as.character(mapdata$totalprofit))
#查看缺失值
#sum(is.na(mapdata)) #无缺失值
#将数据加入地图
ordersmap <- joinCountryData2Map(mapdata,joinCode = 'ISO3',
nameJoinColumn = 'ISO3c')
classInt <- classIntervals( ordersmap[["totalprofit"]], n=5,
style="jenks")
catMethod = classInt[["brks"]]
colourPalette <- brewer.pal(5,'PuBu')
mapPDF <- mapCountryData(ordersmap,nameColumnToPlot = 'totalprofit'
, mapTitle = "全球销售利润地图"
, addLegend = F, catMethod = catMethod
, colourPalette = colourPalette)
do.call( addMapLegend, c( mapPDF, legendLabels="all", legendWidth=0.5,
legendIntervals="data", legendMar = 2 ))可以看到,在美国、加拿大、大洋洲,中国,拉丁美洲中部等地区的销售利润最高,是公司主要的市场。
#拉丁美洲
profit_LatinAmerica <- orders %>% filter(market=='拉丁美洲')%>%group_by(year)%>%summarise(totalprofit=sum(profit))
#绘制拉丁美洲利润折线图
ggplot(profit_LatinAmerica,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+5000,label=round(totalprofit,2)))+
scale_fill_brewer(palette="GnBu")+
bbc_style()+
labs(title = "2011-2014年拉丁美洲利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,拉丁美洲的利润总额呈上升趋势,特别地,拉丁美洲的利润四年来翻了两翻,增长形势较好。
#欧盟
profit_EuropeanUnion <- orders %>% filter(market=='欧盟')%>%group_by(year)%>%summarise(totalprofit=sum(profit))
ggplot(profit_EuropeanUnion,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+6000,label=round(totalprofit,2)))+
bbc_style()+
labs(title = "2011-2014年欧盟利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,欧盟的利润总额呈上升趋势,特别地,欧盟作为发达国家集中地区,居民购买力较强,欧盟的利润四年来翻了两翻,增长形势较好。
#亚太地区
profit_AsiaPacific <- orders %>% filter(market=='亚太地区')%>%group_by(year)%>%summarise(totalprofit=sum(profit))
ggplot(profit_AsiaPacific,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+10000,label=round(totalprofit,2)))+
bbc_style()+
labs(title = "2011-2014年亚太地区利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,亚太地区近四年来市场逐渐开始疲软,但依托于中国、日本、澳大利亚等区域经济大国,总体利润体量保持在一个较高水平。
#美国
(profit_USA <- orders %>% filter(market=='美国')%>%group_by(year)%>%summarise(totalprofit=sum(profit)))## # A tibble: 4 x 2
## year totalprofit
## <chr> <dbl>
## 1 2011 49544.
## 2 2012 61619.
## 3 2013 81727.
## 4 2014 93508.
ggplot(profit_USA,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+5000,label=round(totalprofit,2)))+
bbc_style()+
labs(title = "2011-2014年美国利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,美国是该公司不可忽视的重要市场,近四年来该公司在美国市场的利润总体呈上升趋势,且作为单个国家,体量较为庞大。
#EMEA
profit_EMEA <- orders %>% filter(market=='EMEA')%>%group_by(year)%>%summarise(totalprofit=sum(profit))
ggplot(profit_EMEA,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+1500,label=round(totalprofit,2)))+
bbc_style()+
labs(title = "2011-2014年EMEA利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,除欧盟外欧洲国家及中东地区及非洲部分国家消费者购买力明显弱于其他地区,但市场仍有较大开辟空间,在2013至2014年EMEA市场利润有较大提升。
#非洲
profit_Africa <- orders %>% filter(market=='非洲')%>%group_by(year)%>%summarise(totalprofit=sum(profit))
ggplot(profit_Africa,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+3000,label=round(totalprofit,2)))+
bbc_style()+
labs(title = "2011-2014年非洲利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,由于非洲不发达地区较多,居民消费水平同亚太地区有显著差异,但考虑到发展中国家发展趋势近年来不断向好,非洲地区自2012年伊始利润不断大幅度增长,相信在未来拥有广阔市场前景。
#加拿大
profit_Canada <- orders %>% filter(market=='加拿大')%>%group_by(year)%>%summarise(totalprofit=sum(profit))
ggplot(profit_Canada,aes(x=year,y=totalprofit,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=totalprofit+400,label=round(totalprofit,2)))+
bbc_style()+
labs(title = "2011-2014年加拿大利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从上图可以看出,加拿大作为单独的一个地区体量较小,虽然在2011-2012年有一个较大跃迁,但总体利润额较小,未来可考虑将加拿大与美国市场合并为北美市场。
#market利润集中折线图
orders %>%group_by(year,market) %>% summarise(totalprofit=sum(profit)) %>%
ggplot(.,aes(x=year,y=(totalprofit),color=factor(market),group=market))+geom_line(size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+#底线
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
geom_point(size=3, shape=20)+
#geom_text(aes(y=totalprofit,label=round(totalprofit)),size=3)+
scale_fill_brewer(palette="GnBu")+
bbc_style()+
labs(title = "2011-2014年各大market利润分布",y="利润",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),##表格题目
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),#坐标轴字体
axis.text = element_text(size = 10),#坐标数字大小
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))#图例字大小综合分析来看,我们得出结论:该公司在全球各大市场2011至2014年总体呈上升趋势,由增长情况可以看出,亚太地区、欧盟、美国、拉丁美洲可作为该公司的第一梯队目标市场,非洲、EMEA、加拿大地区作为第二梯队目标市场。同时可以粗略看出各市场利润增长情况普遍与市场份额较为吻合,若分析各市场持续发展能力我们引入市场利润增长率进行辅助分析。
profit_year_market<-orders %>%select(year,market,profit) %>% group_by(market,year) %>%
summarise(totalprofit=sum(profit))%>%mutate(ratio = ((totalprofit-lag(totalprofit))/lag(totalprofit)))
ggplot(filter(profit_year_market,year!=2011),aes(x=year,y=ratio,colour=factor(market),group=(market)))+geom_line(size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20)+
#geom_text(aes(y=ratio,label=round(ratio)))+
bbc_style()+
labs(title = "2011-2014年市场利润增长情况",y="利润增长率",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),##表格题目
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),#坐标轴字体
axis.text = element_text(size = 10),#坐标数字大小
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))#图例字大小通过分析利润增长情况,我们可以看出,该公司主要目标市场亚太地区、美国、欧盟发展情况已趋于稳定,加拿大市场在经历最初的发展跃迁之后也趋于稳定,作为新兴力量的拉美市场在2014年利润增长率依然高歌猛进,保持在1以上,可以在未来进行适当加大该区域业务量。
该部分分析旨在横向比较各年度内各市场利润份额,进一步深化目标市场的确定,为未来产品、订单的投放市场给出建议
#2011年
sum_profit<-as.numeric(orders %>% filter(year=="2011")%>%
summarise(sum_profit = sum(profit)))
profit_2011_2014<-orders%>%select(year,market,profit)%>%group_by(market,year)%>%summarise(totalprofit=sum(profit))%>%
mutate(Percentage=totalprofit/sum_profit)
#ggplot(profit_2011, aes(x=market, y=totalprofit)) + geom_bar(stat="identity")
ggplot(profit_2011_2014,aes(x=market, y=Percentage,fill=market)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~year)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE")))
scale_fill_brewer(palette="PuBu")+
bbc_style()+
#geom_text(aes(y=Percentage,label=round(Percentage)))
labs(title = "2011-2014各年各市场份额",y="份额",x="市场")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))由上图可以看出,各市场由于地缘、人群等条件限制,近四年来各市场利润份额并无太大变化,亚太地区、欧盟、美国三市场作为主要市场依然是公司业务发展的持续动力
接下来进一步探索各市场下各区域利润分布情况。
#各区
profit_market_area <- orders %>% select(market,area,profit) %>% unite(marketarea,market,area,sep='-')%>%group_by(marketarea) %>% summarise(totalprofit=sum(profit))
ggplot(profit_market_area,aes(y=totalprofit,x=marketarea,fill=marketarea))+
geom_bar(stat = "identity",position = position_dodge(0.7),width = 0.6)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
coord_flip()+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE")))
#scale_fill_brewer(palette="GnBu")+
bbc_style()+
#geom_text(aes(x=totalprofit,label=round(totalprofit)))
#geom_text(mapping = aes(label = x))
labs(title = "各市场区域利润份额",y="市场区域",x="利润")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 8),
axis.text = element_text(size = 9),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'none',legend.title = element_blank(),
legend.text = element_text(size = 8))从上图中可以看出,亚太地区作为第一大市场,中亚、大洋洲、北亚地区利润势头较好,东南亚地区利润水平较低,只与最小市场加拿大持平;欧盟市场则是以法国、德国为代表的欧盟中部地区在全部细分市场的区域当中利润水平最高,应在未来加大该地区业务量;美国市场则是以加州为代表的美国西海岸以及纽约州为代表的的美国东海岸地区为主要利润较高区域;拉丁美洲市场则是靠近美国的墨西哥区域利润水平较高。综上所述,应在各市场分配业务部署时,针对上述区域加大业务量。
1、亚太地区、欧盟、美国三大市场作为主要目标市场应着重未来发展,持续增大获利能力。
2、拉丁美洲市场作为发展中市场应加大业务投放,并时刻进行数据观测,探索其业务可接受范围峰值。
3、非洲、EMEA市场由于其本身地区发展状况限制,现阶段获利能力不足,在业务投放时要根据热销产品类型有针对投放。
4、建议加拿大市场与美国市场合并为北美市场。
profit_market_type <- orders %>% select(market,type,profit) %>% group_by(market,type)%>%
summarise(sum=sum(profit))
ggplot(profit_market_type,aes(x=type,y=sum, fill=market)) +
geom_bar(stat="identity",position="dodge") +
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年各市场在各类产品的利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(profit_market_type,aes(x=type,y=sum, fill=market)) +
geom_bar(stat="identity",position="fill") +
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年各市场在各类产品的利润占比",y="利润占比",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))由上两张图可见,除了欧盟和亚太地区之外,其他地区的由技术类产品带来的利润最多,其次是办公用品,家具类产品带来的利润最少。欧盟地区办公用品带来的利润第一,技术类第二,家具第三,亚太地区技术类第一,家具第二,办公用品第三。
同时,欧盟在办公用品带来的利润中占比最大,美国和亚太地区其次;亚太地区在技术带来的利润中占比最大,美国和欧盟其次;亚太地区在家具带来的利润中占比最大,欧盟和加拿大其次。
因此,可以得到,亚太地区、欧盟、和美国是该公司的主要市场,需要有更多的产品供给。细分到各个市场,亚太地区需要供给最大量的家具类产品和技术类产品,以及较大量办公用品;欧盟需要最大量的办公用品,以及较大量的技术类产品和家具类产品;美国需要大量办公用品和技术类产品,但是对家具类产品需求较小;拉丁美洲、非洲、加拿大和EMEA地区对三类产品的需求相近,且需求相比之下较低。
非洲、加拿大和EMEA未细分地区,同上.
profit_area_type <- orders %>% select(market,area,type,profit) %>% group_by(market,area,type)%>%summarise(sum=sum(profit))
#画出各个地区三个类别的获利
ggplot(filter(profit_area_type,market=="拉丁美洲"),aes(x=type,y=sum,fill=type)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年拉丁美洲各产品类型利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))由上图可知,拉丁美洲各地区对三类产品的需求较不平均,北部对技术类产品和办公用品需求十分大,带来了巨大的利润,其他地区对这两类产品的需求较为平均;另外,中部对家具的需求十分大,其他地区对家具的需求较为平均。
因此,可以得到,在拉丁美洲北部需要供给大量的技术类产品和办公用品,在中部需要供给大量的家具类产品,其他地区三类产品近乎平均供给。
ggplot(filter(profit_area_type,market=="美国"),aes(x=type,y=sum,fill=type)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年美国各产品类型利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))由上图可知,美国各地区对三类产品的需求不平均,东部和西部对技术类产品和办公用品需求十分大,带来了巨大的利润,中部地区对技术类产品需求较大,但对办公用品需求较小,南部地区对上述两类产品需求都较小。另外,美国对家具类产品需求较小,尤其是中部地区,家居类产品呈亏损状态。
因此,可以得到,在美国东部、西部需要供给大量办公用品和技术类产品,在中部需要较大量技术类产品,各地区的家具供给只需少量,尤其在中部需要更少家具供给或促销以消除亏损。
ggplot(filter(profit_area_type,market=="欧盟"),aes(x=type,y=sum,fill=type)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年欧盟各产品类型利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))由上图可知,欧盟中部需要对三类产品的需求都较大,北部对技术类产品的需求适中,南部对办公用品需求适中。
因此,可以得到,需要在欧盟中部投放大量的三类产品供给,北部以技术类产品为主,南部以办公用品为主。
ggplot(filter(profit_area_type,market=="亚太地区"),aes(x=type,y=sum,fill=type)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_brewer(palette = "PuBu")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年亚太地区各产品类型利润",y="利润",x="产品类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))由上图可知, 北亚对三种产品的需求最大,尤其是对技术类产品的需求,大洋洲和中亚的需求适中,而东南亚对三类产品的需求较小,尤其是家具类产品,呈现亏损状态。
因此,可以得到,在亚太地区,可以在三类产品主要投放在北亚,大洋洲和中亚,其中北亚需要最大供给量,而东南亚的产品供给需要相对较少,甚至在家具类产品上,需要减少供给或采取促销手段消除亏损状态。
1.亚太地区,欧盟、美国和拉丁美洲是主要市场。
2.该公司应该针对不同市场的特征,采取不同的销售策略,做到细分市场。
3.亚太地区、欧盟、和美国是该公司的主要市场,需要有更多的产品供给。细分到各个市场,亚太地区需要供给最大量的家具类产品和技术类产品,以及较大量办公用品;欧盟需要最大量的办公用品,以及较大量的技术类产品和家具类产品;美国需要大量办公用品和技术类产品,但是对家具类产品需求较小;拉丁美洲、非洲、加拿大和EMEA地区对三类产品的需求相近,且需求相比之下较低。
4.在拉丁美洲北部需要供给大量的技术类产品和办公用品,在中部需要供给大量的家具类产品,其他地区三类产品近乎平均供给。
5.在美国东部、西部需要供给大量办公用品和技术类产品,在中部需要较大量技术类产品,各地区的家具供给只需少量,尤其在中部需要更少家具供给或促销以消除亏损。
6.在欧盟中部投放大量的三类产品供给,北部以技术类产品为主,南部以办公用品为主。
7.在亚太地区,可以在三类产品主要投放在北亚,大洋洲和中亚,其中北亚需要最大供给量,而东南亚的产品供给需要相对较少,甚至在家具类产品上,需要减少供给或采取促销手段消除亏损状态。
客户是利润的直接带来者,因此分析客户带来的利润可以有效识别重要客户。
#寻找带来利润最大的消费者 >7000
profit_customer <- orders %>% select(custname,profit,quantity,sales) %>%group_by(custname)%>%
summarise(sum_profit=sum(profit),sum_quantity=sum(quantity),sum_sales=sum(sales)) %>%
filter(sum_profit>7000)%>%arrange(desc(sum_profit))
profit_customer## # A tibble: 7 x 4
## custname sum_profit sum_quantity sum_sales
## <chr> <dbl> <dbl> <dbl>
## 1 孟斯云 8673. 271 37457.
## 2 柯强 8453. 262 29602.
## 3 田谙 8396. 645 50732.
## 4 郝升 8205. 244 26521.
## 5 施菊 7817. 207 30244.
## 6 黄丽 7789. 584 51928.
## 7 田诚 7410. 411 28479.
可以看到孟斯云、柯强、田谙等7月顾客在过去4年内为公司带来了大量利润。
####时间与业绩表现的关系
#年度产品的销售量分布
quantity_all_year <- orders %>% select("year","quantity") %>%group_by(year) %>% summarise(sum_year=sum(quantity))
#年度销售量折线图
ggplot(quantity_all_year, aes(x=year, y=sum_year,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=sum_year+5000,label=round(sum_year,2)))+
bbc_style()+
labs(title = "2011-2014年销售量分布",y="销售量",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))#年度产品的销售额分布
sales_all_year <- orders %>% select("year","sales") %>%group_by(year) %>% summarise(sum_year_sales=sum(sales))
#年度销售额折线图
ggplot(sales_all_year, aes(x=year, y=sum_year_sales,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
geom_text(aes(y=sum_year_sales+200000,label=round(sum_year_sales,2)))+
bbc_style()+
labs(title = "2011-2014年销售额分布",y="销售额",x="年份")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10))从图中可以看出随着时间的推移,无论是销售额还是销售量都是逐步上升且保持一个良好势头的,公司可能正处在发展期的阶段。
####区域与业绩表现的关系
#各区域的销售额分布
sales_area <- orders %>% select("market_area","sales") %>%group_by(market_area) %>% summarise(sum_area_sales=sum(sales))
#不同区域销售额折线图
ggplot(sales_area, aes(x=market_area, y=sum_area_sales,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
#geom_text(aes(y=sum_area_sales+20000,label=round(sum_area_sales)))+
bbc_style()+
labs(title = "不同区域销售额分布",y="销售额",x="区域")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10,angle = 90, hjust = 1))#各区域的销售量分布
quantity_area <- orders %>% select("market_area","quantity") %>%group_by(market_area) %>% summarise(sum_area_quantity=sum(quantity))
#不同区域销售量折线图
ggplot(quantity_area, aes(x=market_area, y=sum_area_quantity,group=1)) +
geom_line(colour= "#1380A1",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=4, shape=20,colour="#1380A1")+
#geom_text(aes(y=sum_area_quantity,label=round(sum_area_quantity)))+
bbc_style()+
labs(title = "不同区域销售量分布",y="销售量",x="区域")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10,angle = 90, hjust = 1))由图可知,加拿大的销售额最低,欧盟中部的销售额最高,亚太地区大洋洲的销售额紧随其后,公司需要往欧盟地区多发展,并且减少加拿大地区的送货量。
该公司市场的业绩是在逐年上升,整体表现较好,如果公司想增加业绩的话,应该多往欧盟中部地区和亚太地区大洋洲供货,减少在加拿大的供货量。
####产品,时间与业绩的关系
#各产品每年销售额分布
sales_type_year <- orders %>% select(year,type,sales) %>% group_by(year, type) %>%
summarise(sum = sum(sales))
ggplot(sales_type_year, aes(x=year,y=sum,colour=factor(type),group=factor(type))) +
geom_line(size=1)+
facet_grid(.~type)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年各年各类产品销售额",y="销售额",x="年度")+
theme(plot.title = element_text(size=18,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))quantity_type_year <- orders %>% select(year,type,quantity) %>% group_by(year, type) %>%
summarise(sum = sum(quantity))
ggplot(quantity_type_year, aes(x=year,y=sum,colour=factor(type),group=factor(type))) +
geom_line(size=1)+
facet_grid(.~type)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20)+
#geom_text(aes(y=sum+15000,label=round(sum)))+
bbc_style()+
labs(title = "2011-2014年各年各类产品销售量",y="销售量",x="年度")+
theme(plot.title = element_text(size=18,face="bold",
hjust = 0.5),
plot.subtitle = element_text(size = 12,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = 0.5),
legend.position = 'bottom',legend.title = element_blank(),
legend.text = element_text(size = 10))由图可知三种类型产品的销售额与销售量都是在同时增长的,但其中技术品销售额的增长是最快的,家具的增长最慢。说明人们对技术品的需求越来越多,更加注重技术对人们生活带来的便利。同时办公用品的销售量最多而且增长最多,技术和家具的销售量也是在增长,说明办公用品是人们需求最多的产品,是公司的主力产品,公司应该在维持办公用品的前提下继续发展技术品。技术与家具都是该公司的“明星产品”,单件利润比较高;而办公用品是“热销产品”,单件利润不算很高。
#####子类产品 时间与业绩的关系
######办公用品 时间与业绩的关系
#各subtype 各年度销售量分布
subtype_annural_quantity <- orders %>% select("year","subtype","type","quantity") %>% group_by(type,subtype,year) %>% summarise(sum_subtype_quantity_year=sum(quantity))
#各subtype 各年度销售量分布簇状柱形图
ggplot(filter(subtype_annural_quantity,type=="办公用品"),aes(x=subtype, y=sum_subtype_quantity_year, fill=year))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="办公用品类各子产品各年度销售量分布簇状柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(subtype_annural_quantity,type=="办公用品"),aes(year,sum_subtype_quantity_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="stack",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="办公用品各子产品各年度销售量分布堆积柱形图")+
theme(plot.title = element_text(size=14,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10))ggplot(filter(subtype_annural_quantity,type=="办公用品"),aes(year,sum_subtype_quantity_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="fill",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="办公用品各子产品各年度销售量分布百分比堆积柱形图")+
theme(plot.title = element_text(size=14,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10))从图中我们能看出办公产品类销售量居多的是装订机,美术,以及存储;四年来总体销量在不断增多,但是销售量的百分比组成几乎没变,装订机,美术以及存储一直是办公产品类中销售量居多的部分。
#各年不同子产品销售额分布
year_subtype_sales<- orders %>% select("year","type","sales","subtype") %>% group_by(year,type,subtype) %>% summarise(sum_subtype_sales_year=sum(sales))
ggplot(filter(year_subtype_sales,type=="办公用品"),aes(x=year, y=sum_subtype_sales_year, fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="办公用品各年不同子产品销售额分布簇状柱形图")+
theme(plot.title = element_text(size=14,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10))ggplot(filter(year_subtype_sales,type=="办公用品"),aes(year,sum_subtype_sales_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="stack",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="办公用品各年不同子产品销售额分布堆积柱形图")+
theme(plot.title = element_text(size=14,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10))ggplot(filter(year_subtype_sales,type=="办公用品"),aes(year,sum_subtype_sales_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="fill",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="办公用品各年不同子产品销售额分布百分比堆积柱形图")+
theme(plot.title = element_text(size=14,face="bold",hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10))但是我们能发现对销售额起最大贡献的却是存储与电器,这说明存储是办公产品里的“热门产品”,销售量多,利润也高;电器是办公产品里的“明星产品”,虽然销售量不高,但其中有很大的利润。而装订机与美术是“热销产品”,虽然销售量很多但是利润很少,可以用来抢占市场并提升品牌知名度。
######家具 时间与业绩的关系
ggplot(filter(subtype_annural_quantity,type=="家具"),aes(x=subtype, y=sum_subtype_quantity_year, fill=year))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="家具类各子产品各年度销售量分布簇状柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(subtype_annural_quantity,type=="家具"),aes(year,sum_subtype_quantity_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="stack",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="家具各子产品各年度销售量分布堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(subtype_annural_quantity,type=="家具"),aes(year,sum_subtype_quantity_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="fill",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="家具各子产品各年度销售量分布百分比堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))家具类销售量居多的是椅子和用具;四年来总体销量在不断增多,但是销售量的百分比组成几乎没变,椅子及用具一直是家具类中销售量居多的部分,四者销量比例约为。2:3.5:3:1.5.
ggplot(filter(year_subtype_sales,type=="家具"),aes(x=year, y=sum_subtype_sales_year, fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="家具各年不同子产品销售额分布簇状柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 8))ggplot(filter(year_subtype_sales,type=="家具"),aes(year,sum_subtype_sales_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="stack",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="家具各年不同子产品销售额分布堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(year_subtype_sales,type=="家具"),aes(year,sum_subtype_sales_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="fill",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="家具各年不同子产品销售额分布百分比堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))和办公产品的情况一样,我们能发现椅子是家具里的“热门产品”,销售量多,利润也高;书架是家具里的“明星产品”,虽然销售量不高,但其中有很大的利润。而用具是“热销产品”,虽然销售量很多但是利润很少。
######技术 时间与业绩的关系
ggplot(filter(subtype_annural_quantity,type=="技术"),aes(x=subtype, y=sum_subtype_quantity_year, fill=year))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="技术类各子产品各年度销售量分布簇状柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(subtype_annural_quantity,type=="技术"),aes(year,sum_subtype_quantity_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="stack",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="技术各子产品各年度销售量分布堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(subtype_annural_quantity,type=="技术"),aes(year,sum_subtype_quantity_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="fill",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="技术各子产品各年度销售量分布百分比堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))技术类产品中销售量最多的是电话以及配件,四个子产品销售额比例大约是3:2:3:1。
ggplot(filter(year_subtype_sales,type=="技术"),aes(x=year, y=sum_subtype_sales_year, fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="技术各年不同子产品销售额分布簇状柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(year_subtype_sales,type=="技术"),aes(year,sum_subtype_sales_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="stack",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="技术各年不同子产品销售额分布堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))ggplot(filter(year_subtype_sales,type=="技术"),aes(year,sum_subtype_sales_year))+
geom_bar(aes(fill=subtype),stat = "identity",position="fill",width=0.8)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
scale_fill_manual(values = c("#D1E5F0","#92C5DE","#4393C3","#2166AC"))+
labs(title="技术各年不同子产品销售额分布百分比堆积柱形图")+
theme(plot.title = element_text(size=14,hjust = 0.5),
plot.caption = element_text(size=16),
axis.title = element_text(size = 10))电话是技术里的“热门产品”,销售量多,利润也高;复印机是技术里的“明星产品”,虽然销售量不算很高,但其中有很大的利润。而配件是“热销产品”,虽然销售量很多但是利润很少。
#####小结与建议
对于三种不同的产品类别,他们都有属于自己的热门产品,明星产品以及热销产品。热销产品适用于公司的前期推广,能在短时间内最大的提升公司的知名度,帮助打开市场;热门产品为该公司主打产品,可用于巩固公司在市场上的地位,提高公司的市场竞争力;明星产品可在公司在市场上拥有一定影响力后再进行发展,能扩大公司的客户层,也有利于公司转型。而就对三种产品类型而言,办公用品为热销产品,家具以及技术都可以算是明星产品。
####区域 时间与业绩的关系
sales_year_market <- orders %>% select(year,market_area,sales) %>% group_by(year,market_area)%>%
summarise(sum=sum(sales))
ggplot(sales_year_market,aes(x=market_area,y=sum, fill=year)) +
geom_bar(stat="identity",position="fill") +
geom_hline(yintercept = 0,size=1, colour="#333333")+
#scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年各区域销售额占比",y="销售额占比",x="区域")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))##销售量
quantity_year_market <- orders %>% select(year,market_area,quantity) %>% group_by(year,market_area)%>%
summarise(sum=sum(quantity))
ggplot(quantity_year_market,aes(x=market_area,y=sum, fill=year)) +
geom_bar(stat="identity",position="fill") +
geom_hline(yintercept = 0,size=1, colour="#333333")+
#scale_fill_manual(vladingmalues = c("#1380A1","#D1E5F0","92C5DE"))+
bbc_style()+
labs(title = "2011-2014年各区域销售量占比",y="销售量占比",x="区域")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))整体情况我们可以看出,绝大多数地区的销售额与销售量都是随时间增长的。
#####拉丁美洲
#各区域每年销售额
orders<- orders %>%separate(col=market_area,into = c('market','area'),sep = '_')
sales_area_year <- orders %>% select(market,area,year,sales) %>% group_by(market,area,year)%>%summarise(sum=sum(sales))
#画出各个地区销售额
ggplot(filter(sales_area_year,market=="拉丁美洲"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年拉丁美洲各区域销售额",y="销售额",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))#各区域每年销售量
quantity_area_year <- orders %>% select(market,area,year,quantity) %>% group_by(market,area,year)%>%
summarise(sum=sum(quantity))
#画出各个地区销售量
ggplot(filter(quantity_area_year,market=="拉丁美洲"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年拉丁美洲各区域销售量",y="销售量",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))拉丁美洲加勒比海地区是销售额与销售量均为最低的区域,南部销售额与销售量都很高,为热门地区;中部销售量较高但销售额没有那么高,为热销地区;北部销量偏低但销售额较高,为明星区域。
#####美国
ggplot(filter(quantity_area_year,market=="美国"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年美国各区域销售量",y="销售量",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 8),
axis.text = element_text(size = 9),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(filter(sales_area_year,market=="美国"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年美国各区域销售额",y="销售额",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))美国南部销售额与销售量均为最低的区域,西部销售额与销售量都很高,为热门地区;中部销售量较高但销售额没有那么高,为热销地区;东销量偏低但销售额较高,为明星区域。
#####欧盟
ggplot(filter(quantity_area_year,market=="欧盟"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年欧盟各区域销售量",y="销售量",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(filter(sales_area_year,market=="欧盟"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年欧盟各区域销售额",y="销售额",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))欧盟中部销售额与销售量都很高,为热门地区;北部与南部差别不大,都约为中部的一半
#####亚太地区
ggplot(filter(quantity_area_year,market=="亚太地区"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年亚太地区各区域销售量",y="销售量",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))ggplot(filter(sales_area_year,market=="亚太地区"),aes(x=year,y=sum,fill=year)) +
geom_bar(stat="identity",position="dodge") + facet_grid(.~area)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
scale_fill_manual(values = c("#1380A1","#D1E5F0","92C5DE","#1380B2"))+
bbc_style()+
labs(title = "2011-2014年亚太地区各区域销售额",y="销售额",x="年份")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))大洋洲销售额与销售量都很高,为热门地区;东南亚销售量较高但销售额没有那么高,为热销地区;北亚与中亚销售量低但销售额较高,为明星区域。
#####加拿大,EMEA,非洲 由于这三个地方并没有细分区域,研究的意义不大,因此再此不做研究。
#####小结与建议 所有地区的销售量与销售额均为逐渐增长。应针对同一地区的不同区域采用不同的销售策略。
####产品与区域和业绩的关系
#####产品与区域
orders <- orders %>% unite(market_area,market,area,sep="_")
#各产品各区域销售额分布
type_area_sales <- orders %>% select("market_area","type","sales") %>% group_by(type,market_area) %>% summarise(sum_area_type_sales=sum(sales))
#各产品各区域销售额分布簇状柱形图
ggplot(type_area_sales,aes(x=type, y=sum_area_type_sales, fill=market_area))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="各产品各区域销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))我们能发现这三种产品销售额与销售量最多的地方都是欧盟中部,由此可见欧盟中部是该公司最主要的市场;同时技术与家具差异巨大的销售量与销售额也说明了他们明星产品的身份。
#####子产品与区域
######办公产品与区域
#各子产品各区域销售额分布
subtype_area_sales <- orders %>% select("market_area","type","sales","subtype") %>% group_by(type,market_area,subtype) %>% summarise(sum_area_subtype_sales=sum(sales))
#各年不同子产品销售额分布
year_subtype_sales<- orders %>% select("year","type","sales","subtype") %>% group_by(year,type,subtype) %>% summarise(sum_subtype_sales_year=sum(sales))
ggplot(filter(subtype_area_sales,type=="办公用品"),aes(x=market_area,y=sum_area_subtype_sales,fill=market_area))+
geom_bar(stat='identity',position="dodge")+facet_grid(subtype~.)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title = "办公用品子产品各区域销售额分布簇状柱形图",y="销售额",x="地区")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 5),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 10))EMEA,非洲,拉丁美洲以及亚太地区利润来源主要是存储与电器;美国主要利润来源的装订机,存储以及电器;欧盟主要利润来源是存储,电器与美术。
######家具与区域
ggplot(filter(subtype_area_sales,type=="家具"),aes(x=market_area,y=sum_area_subtype_sales,fill=market_area))+
geom_bar(stat='identity',position="dodge")+facet_grid(subtype~.)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title = "家具子产品各区域销售额分布簇状柱形图",y="销售额",x="地区")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))加拿大对于家具的购买额很少,欧盟南部对于书桌的需求量远多于它对其他家具的需求,其余国家与地区对于家具的需求都差不多,主要集中在书架与椅子。
ggplot(filter(subtype_area_sales,type=="技术"),aes(x=market_area,y=sum_area_subtype_sales,fill=market_area))+
geom_bar(stat='identity',position="dodge")+facet_grid(subtype~.)+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title = "技术子产品各区域销售额分布簇状柱形图",y="销售额",x="地区")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8)) 加拿大对于技术产品的需求也很少,同时欧盟中部对于技术产品的需求量远高于其他国家与地区;而其他国家与地区对技术产品的需求也主要集中在电话与复印机。
####区域与产品和业绩的关系
#####区域与产品和业绩的关系
area_type_sales <- orders %>% select("market_area","sales","type") %>% group_by(type,market_area) %>% summarise(sum_area_type_sales=sum(sales))
#各区域各产品销售额分布簇状柱形图
ggplot(area_type_sales,aes(x=market_area, y=sum_area_type_sales, fill=type))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="各区域各产品销售额分布簇状柱形图",y="销售额",x="地区")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))根据这张图可以将地区分为几个等级。一等为欧盟中部,对该公司产品有着强烈的需求;二等为亚太地区,EMEA和非洲,对该公司产品的需求较高;三等为欧盟其他地区与美国,对该公司产品的需求一般;四等为加拿大,对该公司产品的需求很低。
#####EMEA
orders<- orders %>% separate(col=market_area,into = c('market','area'),sep = '_')
area_subtype_sales <- orders %>% select("market","area","type","sales","subtype") %>% group_by(type,market,area,subtype) %>% summarise(sum_area_subtype_sales=sum(sales))
#各区域各子产品销售额分布簇状柱形图
ggplot(filter(area_subtype_sales,market=="EMEA"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="EMEA各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))EMEA销售额最高的为电话,存储和书架。
#####加拿大
ggplot(filter(area_subtype_sales,market=="加拿大"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="加拿大各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))加拿大销售额最高的为存储电话和电器.
#####非洲
ggplot(filter(area_subtype_sales,market=="非洲"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+
bbc_style()+
labs(title="非洲各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))非洲销售额最高的为电话,存储与复印机。
#####拉丁美洲
ggplot(filter(area_subtype_sales,market=="拉丁美洲"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+facet_grid(area~.)+
bbc_style()+
labs(title="拉丁美洲各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))拉丁美洲需求最多的东西是电话,复印机和书架。
#####美国
ggplot(filter(area_subtype_sales,market=="美国"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+facet_grid(area~.)+
bbc_style()+
labs(title="美国各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))美国需求最多的东西是电话,存储和椅子。
#####欧盟
ggplot(filter(area_subtype_sales,market=="欧盟"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+facet_grid(area~.)+
bbc_style()+
labs(title="欧盟各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))欧盟需求最多的东西是存储,电话,复印机以及书架。
#####亚太地区
ggplot(filter(area_subtype_sales,market=="亚太地区"),aes(x=subtype, y=sum_area_subtype_sales,fill=subtype))+
geom_bar(stat='identity',position="dodge")+
geom_hline(yintercept = 0, size = 1, colour = "#333333")+facet_grid(area~.)+
bbc_style()+
labs(title="亚太地区各产品销售额分布簇状柱形图",y="销售额",x="类型")+
theme(plot.title = element_text(size=16,face="bold",
hjust = 0.5),
plot.caption = element_text(size=14,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right',legend.title = element_blank(),
legend.text = element_text(size = 8))亚太地区最需要的东西是电话,复印机,书架与椅子。
####小结与建议 虽然说每个地方的需求都不一样,但是电话是所有国家与地区都需求的东西,其余需求较多的东西为存储,复印机,书架,椅子。
作出时间序列图,观察各年月度销售额分布的图像,可以初步判断出2011-2014年月利润具有趋势性和季节性,属于不平稳序列。
## # A tibble: 48 x 3
## # Groups: year [4]
## year month sum_month
## <chr> <chr> <dbl>
## 1 2011 01 98898.
## 2 2011 02 91152.
## 3 2011 03 145729.
## 4 2011 04 116916.
## 5 2011 05 146748.
## 6 2011 06 215207.
## 7 2011 07 115510.
## 8 2011 08 207581.
## 9 2011 09 290214.
## 10 2011 10 199071.
## # ... with 38 more rows
将数据转换为时间序列数据。
####差分试验
由于原始序列为不平稳序列,对序列图进行拆分:
对原始序列图拆分后可以发现趋势是向上的,同时具有季节性图。 画出季节趋势图:
进行一阶拆分
对拆分后的平稳序列图其画出自相关图与偏相关图。
可以看到ACF几乎看不出截尾,PACF从2开始截尾。说明一阶差分并不有效,在进行计算单位根时P值并不显著,其他不同阶分尝试时发现效果也不尽人意,因而采用ARIMA中的自动建模函数。
####ARIMA自动建模预测
接下来建模并进行残差正态性检验与残差白噪声检验。
## Series: timeSeries_month
## ARIMA(0,1,1)(1,1,0)[12]
##
## Coefficients:
## ma1 sar1
## -0.4808 -0.6020
## s.e. 0.1636 0.1453
##
## sigma^2 estimated as 1.115e+09: log likelihood=-416.02
## AIC=838.04 AICc=838.82 BIC=842.71
##
## Box-Ljung test
##
## data: mod_auto$residuals
## X-squared = 0.043739, df = 1, p-value = 0.8343
观察得残差正态性较好,并且P值=0.8,残差白噪声显著。进行预测并画出图像。
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2015 374051.1 331263.1 416839.2 308612.5 439489.8
## Feb 2015 332359.0 284148.4 380569.6 258627.2 406090.7
## Mar 2015 382384.8 329302.7 435466.9 301202.8 463566.9
## Apr 2015 361788.8 304246.1 419331.4 273784.9 449792.7
## May 2015 429719.6 368038.1 491401.0 335385.9 524053.2
## Jun 2015 556741.8 491182.3 622301.3 456477.2 657006.4
## Jul 2015 399497.9 330277.3 468718.6 293634.1 505361.8
## Aug 2015 536400.5 463702.9 609098.1 425219.1 647581.9
## Sep 2015 576343.9 500328.2 652359.6 460087.9 692599.9
## Oct 2015 503011.4 423816.4 582206.3 381893.2 624129.6
## Nov 2015 604264.0 522012.6 686515.3 478471.4 730056.5
## Dec 2015 602453.0 517254.9 687651.2 472153.7 732752.4
上图中2015至2016年为预测各月销额与包含置信区间的预测,从对公司总销额的时间序列分析与预测来看,公司总体销售额是稳步上升的,每年内各月总销额也是稳步上升,有着明显的季节性与趋势性加和的特性,在2015年内公司的各月销售额由30万缓慢波动升至接近70万。
根据2011至2014年各个月份的利润,预测2015年1月至12月的利润情况
根据前面对利润与时间的分析可以得到:2011至2014年月利润具有趋势性和季节性。
#综合月度利润折线图
(profit_all_month <- orders %>% select("year",'month',"profit") %>%group_by(year,month) %>% summarise(sum_month=sum(profit)))## # A tibble: 48 x 3
## # Groups: year [4]
## year month sum_month
## <chr> <chr> <dbl>
## 1 2011 01 8322.
## 2 2011 02 12418.
## 3 2011 03 15304.
## 4 2011 04 12902.
## 5 2011 05 12184.
## 6 2011 06 23415.
## 7 2011 07 5585.
## 8 2011 08 23714.
## 9 2011 09 35777.
## 10 2011 10 25963.
## # ... with 38 more rows
profit_all_month <- profit_all_month %>% unite(year_month,year,month,sep = '-')
ggplot(profit_all_month, aes(x=year_month, y=sum_month,group=1)) +
geom_line(colour= "#2166AC",size=1)+
geom_hline(yintercept = 0,size=1, colour="#333333")+
geom_point(size=3, shape=20,colour="#2166AC")+
#geom_text(aes(y=sum_season+15000,label=round(sum_season)))+
bbc_style()+
labs(title = "2011-2014年各月度利润分布",y="利润",x="月度")+
theme(plot.title = element_text(size=14,face="bold",
hjust = 0.5),
plot.caption = element_text(size=16,face="bold"),
axis.title = element_text(size = 10),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5))将数据转换为时间序列数据
## Jan Feb Mar Apr May Jun Jul
## 2011 8321.801 12417.907 15303.568 12902.324 12183.829 23415.247 5585.004
## 2012 10401.638 15000.096 17992.918 17366.967 29876.704 34407.154 15585.388
## 2013 26810.560 23762.496 23433.775 19462.038 28495.694 45478.413 28863.827
## 2014 28001.386 19751.700 37357.261 23782.301 33953.558 43778.603 28035.873
## Aug Sep Oct Nov Dec
## 2011 23713.668 35776.884 25963.418 32709.178 40647.984
## 2012 43573.879 27776.180 30662.883 31820.722 32950.751
## 2013 31023.668 38905.668 42433.223 48062.997 50202.871
## 2014 53542.895 67979.451 58209.835 62856.588 46916.521
首先,利用auto.arima自动进行ARIMA建模
## Series: timeSeries_month
## ARIMA(0,0,0)(1,1,0)[12] with drift
##
## Coefficients:
## sar1 drift
## -0.5235 605.7060
## s.e. 0.1617 82.3471
##
## sigma^2 estimated as 66451012: log likelihood=-376.19
## AIC=758.38 AICc=759.13 BIC=763.13
得到ARIMA的参数为ARIMA(0,0,0)(1,1,0)[12]
然后进行预测,并画出图像
可以发现,预测出的2015年的利润基本符合趋势性和季节性
接着进行残差正态性检验和残差白噪声检验
##
## Box-Ljung test
##
## data: mod_auto$residuals
## X-squared = 2.3387, df = 1, p-value = 0.1262
可以发现,尽管预测结果不错,但是检验结果不尽如人意。所以,我们打算对原始序列进行差分。
首先,对原始序列进行ACF和PACF检验
发现ACF和PACF图像截尾现象并不明显,由之前的结论得到具有趋势性和季节性,所以先对对原始序列图进行拆分
可以发现趋势是向上的,同时具有季节性图,单独拿出季节趋势图进行分析,发现与之前分析的相似
进行一阶差分,并画出其图像以及ACF和PACF图像
发现ACF图像在6之后开始截尾,PACF图像在1之后开始截尾,于是,ARIMA模型参数为6,1,1.
进行建模,并进行残差正态性检验和残差白噪声检验
##
## Call:
## arima(x = timeSeries_month, order = c(6, 1, 1), seasonal = list(order = c(0,
## 1, 0), period = 1, transform.par = F, fixed = c(NA, 0, 0, NA)))
##
## Coefficients:
## ar1 ar2 ar3 ar4 ar5 ar6 ma1
## -0.3836 -0.2022 -0.0417 -0.3312 -0.1963 0.2328 -1.0000
## s.e. 0.1496 0.1601 0.1520 0.1561 0.1686 0.1582 0.0632
##
## sigma^2 estimated as 90693553: log likelihood = -490.04, aic = 996.09
##
## Box-Ljung test
##
## data: mod1$residuals
## X-squared = 0.036112, df = 1, p-value = 0.8493
得到残差正态性较好,并且P值=0.8,残差白噪声显著。进行预测并画出图像。
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2015 40701.13 28362.01 53040.26 21830.07 59572.19
## Feb 2015 54110.55 39476.16 68744.94 31729.18 76491.92
## Mar 2015 56283.09 39908.36 72657.82 31240.10 81326.08
## Apr 2015 56744.52 38435.35 75053.69 28743.06 84745.98
## May 2015 63492.41 44687.08 82297.74 34732.14 92252.68
## Jun 2015 55441.72 35998.28 74885.17 25705.54 85177.91
## Jul 2015 54002.40 32297.43 75707.37 20807.52 87197.29
## Aug 2015 60098.53 37329.02 82868.04 25275.57 94921.49
## Sep 2015 58222.00 34019.43 82424.56 21207.37 95236.63
## Oct 2015 60873.19 35036.30 86710.08 21359.07 100387.30
## Nov 2015 65263.87 38701.58 91826.16 24640.36 105887.39
## Dec 2015 61165.32 33586.17 88744.48 18986.64 103344.00
可以发现,预测结果符合预期,具有趋势性和季节性。
在预测公司利润时间序列时,该序列具有趋势性和季节性。虽然使用ARIMA自动建模令其AIC和BIC最小,可以得到期望的结果,但是其检验效果不佳。因此,对序列进行一阶差分,并根据ACF和PACF图像得到模型ARIMA(6,1,1),其结果和检验效果都较佳。
2.3.2.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1
上图中2015至2016年为预测各月销额,从对公司总销额的时间序列分析与预测来看,
公司总体销售额是稳步上升的,每年内各月总销额也是稳步上升,在2015年内公司的各月销售额由27万缓慢波动升至接近70万。
总体结论:
公司目前在EMEA、非洲、加拿大、拉丁美洲、美国、欧盟以及亚太地区均有市场分布。我们从2011~2014四年市场整体的销售情况分析得到,亚太地区、欧盟、美国、拉丁美洲为主流市场,而其中亚太地区的市场销售额最高。在非洲、EMEA(即欧洲、中东、非洲三地区的加总)地区则销售额接近,占据市场份额比例很小。从区域来说,公司最主打的区域为欧盟中部,应该牢牢巩固住公司在欧盟中部市场上的地位。
四年内公司各个市场销售额均有增长,每年的销售额稳步上升,市场情况较为稳定。具体来看,拉丁美洲增长量最大,加拿大增长最少。我们认为加拿大市场盈利不足。从各市场销售额的同比增长率来看,市场呈现缓慢增长的态势。我们预测公司具有稳步上升的良好发展趋势。
我们从市场分布的另一个角度即购买群体分析得到,在不同地区的购买人群均为消费者>公司>家庭办公室,在购买不同产品的人群中,消费者所占比例最高。
对于公司产品的不同种类,各个市场的产品购买数量均为办公用品>家具>技术,进一步分析公司的五种优势产品分别为:装订机、纸张、椅子、美术用品、存储用品。拉丁美洲、美国、欧洲、亚太地区五种优势产品的销量均很高,其中美国和欧盟地区表现出对某些产品有较大偏爱。
公司整体表现像是一个处于发展期的公司,销售量以及销售额每年都在逐步增长,公司前景一片大好,而且公司朝向多元化发展,定能在市场上立稳脚跟并稳固发展。
建议:
整体销售市场分布较为均衡,但非洲、欧洲、加拿大地区有待加强,应该进一步拓宽市场。加拿大市场盈利不足,存在问题,公司应积极采取策略应对。
对于有偏爱的市场,比如美国和欧洲,可以适当发挥其偏爱产品的优势,扩大销售量与市场销售额。
应多发展技术类产品,尤其是其中的明星产品复印机以及热门产品电话,不断发展科技;应降低购买量以及利润都低的产品的增长幅度,如标签等。
对于第二层的亚太地区,EMEA和非洲,该公司在市场上拥有一定的影响力,应提高企业影响力,发展存储以及电话,书架等产品;对于第三层的欧盟其他地区与美国,发展热门产品与热销产品,需要进一步扩大企业的知名度以及影响力;对于处于第四层的加拿大,公司应该采取大力宣传的策略。若一定时间内市场开拓有困难,则考虑与美国市场合并为北美市场。
由利润时间序列预测分析得:预测出的利润下降点时加大促销力度,预测出的利润高的时加大宣传力度。
本次数据分析耗时 1.2 分钟。