繁体   English   中英

R-如何累计plot行

[英]R- how to plot cumulative lines

我的问题如下:

我必须 plot 一条曲线,它显示按使用寿命 (x) 划分的故障次数 (y),但以累积的方式 - 这就是我挣扎的地方!

解决方案在第二张图片中,我的代码在第一张中(我认为只有 plot 的类型应该不同)

我的代码解决方案

非常感谢您的帮助!!

我无法复制你的数据,所以这更像是一个评论,然后是一个完整的解决方案。

n <- sum(h$counts)          # This should sum up to the number of observations
y <- cumsum(h$counts) / n   # Your y values
x <- h$mids                   # I assume these to be your x-axis value, but this might need an edit.
plot(x = x, y = y, type = "l")

最后,您可以通过abline() function 在相应的点添加垂直线和水平线。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM