简体   繁体   中英

R- how to plot cumulative lines

my problem is the following:

I have to plot a curve which shows the number of breakdowns (y) by the service life (x) but in a cumulative way - and that's the point where I struggle!!

The solution is given in the second Picture, my code in the first (I think only the type of the plot should be different)

my code solution

Thanks so much for every help!!

I can't replicate your data, so this is more of a comment, then a complete solution.

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")

Finally, you can add the vertical and horizontal lines via the abline() function at the respective points.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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