我正在使用Anomalize包检测异常,但是即使定义了Dateas索引,也遇到了上述错误:
样例代码:
x <- as.data.frame(data %>%
group_by(date,acc_id) %>%
summarise(count = as.numeric(n_distinct(d_id))) %>%
ungroup())
x$acc_id <- as.character(x$acc_id)
x <- x %>%
tibbletime::as_tbl_time(index = date)
x %>%
time_decompose(count, method = "twitter", trend = "2 months") %>%
anomalize(remainder, method = "gesd") %>%
time_recompose() %>%
plot_anomalies(time_recomposed = TRUE)
Run Code Online (Sandbox Code Playgroud)
错误:
mutate_impl(.data,点)中的错误:评估错误:类Date的索引只允许年,季度,月,周和日的时间段。
dput(head(x))
structure(list(date = structure(c(17532, 17532, 17532, 17532, 17532, 17532), class = "Date"), acc_id = c("a44444", "gg555", "0195459b-5809-4b54-89b5-1a4376c9f126", "ggg6546", "hhjh77", "hhjh68777"), count = c(3, 1, 1, 1, 1, 1)), .Names = …Run Code Online (Sandbox Code Playgroud)