business-science / anomalize

Tidy anomaly detection
https://business-science.github.io/anomalize/
338 stars 60 forks source link

Evaluation error: Only year, quarter, ... #24

Closed kempspo closed 5 years ago

kempspo commented 5 years ago

I'm getting this error.

Error in mutate_impl(.data, dots) : Evaluation error: Only year, quarter, month, week, and day periods are allowed for an index of class Date.

I checked the class for my date column and it returns "Date" similar to that of the date column in the example data set. An example of what's in the date column is 2014-12-04

This is the script that I run: twitter.df %>% time_decompose(count, method = "twitter", trend = "2 months") %>% anomalize(remainder, method = "gesd") %>% time_recompose() %>% plot_anomalies(time_recomposed = TRUE) I can't seem to figure out the problem with it. I've tried updating the packages and reloading them.

pedropenzuti commented 5 years ago

Could we get an update on this? Facing the same error.

mdancho84 commented 5 years ago

Please provide a reproducible example.

pedropenzuti commented 5 years ago

Ended up finding a solution through the tidyquant package. The problem arises because the columns are not periods. We can fix that by doing:

tq_transmute(
count, # or whatever variable you want
mutate_fun = to.period,
period = "day" # or whatever period you want)

It should work after that.

mdancho84 commented 5 years ago

OK, I'm going to close since it appears not to be an issue with the package.