[英]R scripting Error { : missing value where TRUE/FALSE needed on Dataframe
[英]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.