2016-08-30 69 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