mutate_impl(.data,点)中的错误:评估错误:类Date的索引只允许年,季度,月,周和日的时间段 [英] Error in mutate_impl(.data, dots) : Evaluation error: Only year, quarter, month, week, and day periods are allowed for an index of class Date

查看:162
本文介绍了mutate_impl(.data,点)中的错误:评估错误:类Date的索引只允许年,季度,月,周和日的时间段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Anomalize包来检测异常,但是即使将Date定义为索引,我也遇到了上述错误:

I am using Anomalize package to detect the Anomalies, but I am getting the mentioned error even though I have defined the Date as index :

示例代码:

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,点)中的错误:评估错误:仅年份, 允许季度,月,周和日为索引的 课程日期.

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")

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

I have the objective to group by date and some other factor not alone with the date.

推荐答案

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

I had the same issue. What helped me was to correctly define your date format:

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

x %>% 
  as_period("daily")

这篇关于mutate_impl(.data,点)中的错误:评估错误:类Date的索引只允许年,季度,月,周和日的时间段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆