gpt4 book ai didi

r - mutate_impl(.data, dots) 中的错误 : Evaluation error: Only year, Date 类索引允许季度、月、周和日期间

转载 作者:行者123 更新时间:2023-12-01 11:16:31 24 4
gpt4 key购买 nike

我正在使用 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)

错误:

Error in mutate_impl(.data, dots) : Evaluation error: Only year, quarter, month, week, and day periods are allowed for an index of class 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")

我的目标是按日期和其他一些因素进行分组,而不仅仅是日期。

最佳答案

我遇到了同样的问题。帮助我的是正确定义你的日期格式:

library(tibbletime)
x <- as_tbl_time(x, index = date)

x %>%
as_period("daily")

关于r - mutate_impl(.data, dots) 中的错误 : Evaluation error: Only year, Date 类索引允许季度、月、周和日期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50248133/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com