我正在用R.分析SCADA数据
我需要解决的问题是分析SCADA进料并确定测量超过一定限度超过15分钟的频率。
我唯一的方法……
如果您的时间序列是1分钟的时间序列(即:1分钟时间段的时间序列),则很容易使用超过某个阈值的间隔长度 rle :
rle
xx = rle(turb >1.5) sum(xx$values==TRUE & xx$lengths >=15)
所以这里为了得到这个时间系列,一个解决方案是近似它以创建一个更准确的新时间系列。
library(xts) xx = xts(turb,time) yy = na.approx(merge(xts(,seq.POSIXt(min(time),max(time),by=1)), xx)) ## optional plot the new and the old time series plot(x = yy, xlab = "Time", minor.ticks = FALSE, col = "red") points(x = xx, col = "darkgreen",pch=20)
然后我计算间隔的数量,如上所述:
xx = rle(as.vector(coredata(yy>1.5))) sum(xx$values==TRUE & xx$lengths >=15) [1] 6
注意:这里我发现只有6个间隔..