簡體   English   中英

如何在需要TRUE / FALSE的情況下避免R AnomalyDetectionTs錯誤缺少值

[英]How to avoid R AnomalyDetectionTs Error missing value where TRUE/FALSE needed

我對AnomalyDetection R包的AnomalyDetectionTs函數有問題:

遵循此帖子: 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 ...

問題在於only_last='day'不正確, only_last需要設置為T(rue)或F(alse)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM