滚动平均值与rollapply但获得非NA值错误

时间:2018-04-01 23:49:32

标签: r

Browse[2]> head(ks)
                    [,1]                 
2014-02-14 14:27:00 "2014-02-14 14:27:00"
2014-02-14 14:32:00 "2014-02-14 14:32:00"
2014-02-14 14:37:00 "2014-02-14 14:37:00"
2014-02-14 14:42:00 "2014-02-14 14:42:00"
2014-02-14 14:47:00 "2014-02-14 14:47:00"
2014-02-14 14:52:00 "2014-02-14 14:52:00"

我正在尝试查找数据框的滚动平均值(ks

avg = rollapply(ks[,1], 2, mean, align='right', fill='extend')

但我收到了错误:

Error in approx(wix, unlist(object[wix]), xout = wrng) : 
  need at least two non-NA values to interpolate
In addition: There were 50 or more warnings (use warnings() to see the first 50)

不确定我做错了什么

0 个答案:

没有答案