-1
我的机器故障数据与一列,其限定故障(TBF)之间的时间绘制直线累积次数图表
structure(list(tbf = c(2441, 2934, 4285, 2285, 4027, 2419, 2437, 2519, 3294, 2858, 3023, 2567, 3112, 2283, 3068, 2215, 3915, 2354.290323, 2477, 2258, 2742.5, 5198, 2837, 3282, 2474, 2883, 3837, 5054, 4874, 3559.5, 2783, 4246, 2602)), .Names = "tbf", class = "data.frame", row.names = c(NA, -33L))
我要绘制的累积发生曲线图。我能做到这一点使用
library(ggplot2)
ggplot(mydf, aes(x = tbf)) + stat_ecdf()
不过,我想直线拟合到这个情节。我不想要不平坦的线条,但是有一条直线适合它。我试图
library(dplyr)
# add cumulative time and failures
mydf <- mydf %>% mutate(cumm_time = cumsum(tbf), cumm_fmode = row_number())
# fit linear regression
fit <- lm(cumm_time ~ cumm_fmode, data = mydf)
# plot points
plot(mydf$cumm_time, mydf$cumm_time)
# plot straight line
abline(fit)
我的要求是得到一个人物像::
我在哪里得到它错了吗?任何帮助将不胜感激。