2012-11-12 173 views
4

我希望在R项目绘制一个累积的柱状图,其中在Y轴报道的百分比,而不是频率与Y轴百分比累积的柱状图

x <- c(rnorm(100), rnorm(50, mean=2,sd=.5)) 
h <- hist(x, plot=FALSE, breaks=20) 
h$counts  <- cumsum(h$counts) 
h$density <- cumsum(h$density) 
plot(h, freq=TRUE, main="(Cumulative) histogram of x", col="white", border="black") 
box() 

感谢您的帮助

+0

设置'频率= FALSE'在'HIST(数据频率= FALSE)'你拿概率“百分比”,而不是频率 –

+0

的是它可以添加/更改与行的吧? –

回答

17

”不是个这是经验累积分布函数的图表吗?作为

plot(ecdf(x)) 

主要生产:

enter image description here

2

相关搜索:

plot(sort(x), (1:length(x))/length(x), type="l")