我正在使用Anomalize
包来检测异常,但即使我已将其定义Date
为索引,我也会收到上述错误:
示例代码:
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)
错误 :
mutate_impl(.data, dots) 中的错误:评估错误:对于 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 = c("date", "acc_id", "count"), row.names = c(NA,
-6L), class = c("tbl_time", "tbl_df", "tbl", "data.frame"), index_quo = ~date, index_time_zone = "UTC")
我的目标是按日期和其他一些因素进行分组,而不仅仅是日期。