2016-08-30 74 views
1

我有AnomalyDetection [R包AnomalyDetectionTs功能相关的问题:如何避免[R AnomalyDetectionTs错误遗漏值,其中TRUE/FALSE需要

下面这篇文章:https://blog.twitter.com/2015/introducing-practical-and-robust-anomaly-detection-in-a-time-series

devtools::install_github("twitter/AnomalyDetection") 
library(AnomalyDetection) 

ts_sample = data.frame(count(my_timestamp, 'timestamp')) 

anomalies = AnomalyDetectionTs(ts_sample, 
           max_anoms=0.02, 
           direction='both', 
           only_last='day', 
           plot=TRUE, 
           title = 'Twitter CDMX') 

主要生产了这一点:

Error in if (data_sigma == 0) break : 
    missing value where TRUE/FALSE needed 

我正在使用与官方文档中相同的数据格式,相同的数据类型,相同的数据框大小和相同的参数:

> str(raw_data) 
'data.frame': 14398 obs. of 2 variables: 
$ timestamp: POSIXlt, format: "1980-09-25 14:01:00" "1980-09-25 14:02:00" "1980-09-25 14:03:00" ... 
$ count : num 182 176 184 178 165 ... 
> str(ts_sample) 
'data.frame': 14398 obs. of 2 variables: 
$ timestamp: POSIXlt, format: "2015-12-10 16:15:00" "2016-01-18 22:58:00" "2016-07-29 05:41:00" ... 
$ freq  : num 11 4 1 6 1 5 3 5 4 5 ... 

回答

0

的问题是,only_last='day'不正确,only_last需要要么被设定为T(真)或F(假)。

+0

在我的版本中,only_last = FALSE使用given:异常检测中的错误(ts_sample,max_anoms = 0.02,direction =“both”,: only_last必须是'day'或'hr'。 – alemol