R資料特徵分析
阿新 • • 發佈:2018-12-08
貢獻度分析
barplot(dishdata[,3],col = 'green1',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]) } par(new=T,mar=c(4,4,4,4)) #mar 底、左、上、右邊距 #new如果設定為TRUE,則下一個高階繪圖命令在 #繪製之前不應該像在新裝置上一樣清理框架 points(accratio*10000 ~ c((1:length(accratio)-0.5)),type = 'b',new= T) axis(4,col = 'red',col.axis = 'blue',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,"%"))
先做單邊軸資料
barplot(dishdata[,3],col = ‘green1’,names.arg = dishdata[,2],width = 1,space = 0,
ylim = c(0,10000),xlab = “菜品”,ylab = “盈利:元”)
資料,柱狀顏色,組名,柱寬,間距,y軸刻度,x\y標籤
barplot(dishdata[,3],col = 'red1',names.arg = dishdata[,1],width = 2,space = 0.5,
ylim = c(0,16000),xlab = "菜品",ylab = "盈利:元")
accratio = dishdata[,3]
for (i in 1:length(accratio)) {
accratio[i]=sum(dishdata[1:i,3])/sum(dishdata[,3])
}
構造比例列,如同在Excel裡先複製一列資料,然後通過公式得出累積比例
par(new=T,mar=c(2,8,5,4)) 尚未弄明白
par(new=T,mar=c(8,2,5,4))
points(accratio*10000 ~ c((1:length(accratio)-0.5)),type = ‘b’,new= T)
相當於Y~x
axis(4,col = ‘red’,col.axis = ‘blue’,at = 0:10000,label=c(0:10000/10000))
引數:1=below, 2=left, 3=above and 4=right.
at標記要繪製的點