2018-11-22
阅读量:
945
贡献度分析
贡献度分析又称帕累托分析, 它的原理是帕累托法则又称20/80定律。
同样的投入放在不同的地方会产生不同的效益。例如, 对一个公司来讲,
80%的利润常常来自于20%最畅销的产品, 而其他80%的产品只产生了20%
的利润。
##设置工作空间
#把“数据及程序” 文件夹复制到F盘下, 再用setwd设置工作空间
setwd("F: /数据及程序/chapter3/示例程序")
#读取菜品数据, 绘制帕累托图
dishdata=read.csv(file="./data/catering_dish_profit.csv", header=TRUE)
barplot(dishdata[, 3] , col="blue1", names.arg=dishdata[, 2] , width=1, space=0,
ylim=c(0, 10000) , xlab="菜品", ylab="盈利: 元")
accratio=dishdata[, 3]
for (i in 1: length(accratio) ) {
accratio[i] =sum(dishdata[1: i, 3] ) /sum(dishdata[, 3] )
}p
ar(new=T, mar=c(4, 4, 4, 4) )
points(accratio*10000~c((1: length(accratio) -0.5) ) , new=FALSE, type="b", new=T)
axis(4, col="red", col.axis="red", at=0: 10000, label=c(0: 10000/10000) )
mtext("累积百分比", 4, 2)
points(6.5, accratio[7] *10000, col="red")
text(7, accratio[7] *10000, paste(round(accratio[7] +0.00001, 4) *100, "%") )






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论