累积直方图,Y轴为百分比

Gia*_*ear 5 plot r histogram percentage

我希望在R项目中绘制一个累积直方图,在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()
Run Code Online (Sandbox Code Playgroud)

感谢帮助

Rei*_*son 21

这不是经验累积分布函数的图吗?如在

plot(ecdf(x))
Run Code Online (Sandbox Code Playgroud)

产生:

在此输入图像描述