Closed duncanwil closed 6 years ago
Try reinstalling tibbletime
. You may need to update it to get some of the functions that anomalize
uses.
First off, kudos for this wonderful gift! @mdancho84
Had the same issue as OP and upgrading tibbletime
fixed it; safe to close ticket :+1:
Awesome!!
Hi Matt
I am a newbie to R.
I have tried to run the code from your page https://business-science.github.io/anomalize/ but I just cannot get it to work.
I can install all th packages i need but keep getting an error when i want to view tidyverse_cran_downloads: Error: expr
must quote a symbol, scalar, or call
Below are my initial steps:
##################################################
devtools::install_github("business-science/anomalize",force = TRUE) install.packages("tibbletime")
library(tidyverse) library(anomalize) library(tibbletime)
tidyverse_cran_downloads
###############################################
Can you please help me resolve this issue.
Kind regards
Heinrich
I have tried to run the code from your page https://business-science.github.io/anomalize/ but I get the following problems.
Initially, the first bit of the code that downlaods data from CRAN and then creates the faceted graphs works but when I run it for a second time it tells me
"Error in mutate_impl(.data, dots) : Evaluation error: 'get_index_col' is not an exported object from 'namespace:tibbletime'."
I started again and got this message this time:
"Error:
expr
must quote a symbol, scalar, or call"When I run the next bit of code, # Data Manipulation / Anomaly Detection I get this error message even though I have changed nothing in your code:
"Error:
index
attribute isNULL
. Was it removed by a function call?"When I ran # Anomaly Visualziation, I got this error message:
"Error in eval(lhs, parent, parent) : object 'lubridate_dloads' not found"
My code follows:
Using the anomalize package
https://business-science.github.io/anomalize/
devtools::install_github("business-science/anomalize")
install.packages("anomalize") ... this one did not work for my version of R
library(tidyverse) library(anomalize)
Next, let’s get some data. anomalize ships with a data set called tidyverse_cran_downloads that contains the daily CRAN
download counts for 15 “tidy” packages from 2017-01-01 to 2018-03-01.
tidyverse_cran_downloads %>% ggplot(aes(date, count)) + geom_point(color = "#2c3e50", alpha = 0.25) + facet_wrap(~ package, scale = "free_y", ncol = 2) + theme_minimal() + theme(axis.text.x = element_text(angle = 30, hjust = 1)) + labs(title = "Tidyverse Package Daily Download Counts", subtitle = "Data from CRAN by way of cranlogs package")
Suppose we want to determine which daily download “counts” are anomalous.
It’s as easy as using the three main functions (time_decompose(), a
nomalize(), and time_recompose()) along with a visualization function,
plot_anomalies().
tidyverse_cran_downloads %>%
Data Manipulation / Anomaly Detection
time_decompose(count, method = "stl") %>% anomalize(remainder, method = "iqr") %>% time_recompose() %>%
Anomaly Visualization
plot_anomalies(time_recomposed = TRUE, ncol = 2, alpha_dots = 0.25) + labs(title = "Tidyverse Anomalies", subtitle = "STL + IQR Methods")
If you’re familiar with Twitter’s AnomalyDetection package, you can
implement that method by combining time_decompose(method = "twitter")
with anomalize(method = "gesd"). Additionally, we’ll adjust the
trend = "2 months" to adjust the median spans, which is how Twitter’s
decomposition method works.
Get only lubridate downloads
lubridate_dloads <- tidyverse_cran_downloads %>% filter(package == "lubridate") %>% ungroup()
Anomalize!!
lubridate_dloads %>%
Twitter + GESD
time_decompose(count, method = "twitter", trend = "2 months") %>% anomalize(remainder, method = "gesd") %>% time_recompose() %>%
Anomaly Visualziation
plot_anomalies(time_recomposed = TRUE) + labs(title = "Lubridate Anomalies", subtitle = "Twitter + GESD Methods")
Last, we can compare to STL + IQR methods, which use different
decomposition and anomaly detection approaches.
lubridate_dloads %>%
STL + IQR Anomaly Detection
time_decompose(count, method = "stl", trend = "2 months") %>% anomalize(remainder, method = "iqr") %>% time_recompose() %>%
Anomaly Visualization
plot_anomalies(time_recomposed = TRUE) + labs(title = "Lubridate Anomalies", subtitle = "STL + IQR Methods")