library("knitr") opts_chunk$set(cache=TRUE)
library("tidyverse") library("lubridate") library("detectR")
First we clean up the piwick logs. Two variables allow to filter the dataset more effectively:
logs_board <- get_aggregated_piwick(system.file("extdata/complete_log_clean.csv", package = "detectR"), absolute_days=20, relative_days=0.9)
Then we get the main variable of time variability, which includes seasonal (weekly) variation, general trend on revues.org.
times_decomposition_board <- get_calendar_time_series(logs_board)
We compensate the recorded view with the time variability variables.
logs_board$aggregated_frequent <- correct_time_series(logs_board$aggregated_frequent, times_decomposition_board)
We proceed with anomaly detection, using a restricted cubic spline with 3 knots.
anomaly_detection <- detection_anomalies_rcs(logs_board$aggregated_frequent)
We can get a graph of the anomalies for one article
graph_anomalies_rcs(anomaly_detection, "mots.revues.org/21665")
It is also possible to get the same with adjusted size for sigma ratio for each anomaly (ie to what extent does it affect the variable)
graph_anomalies_rcs(anomaly_detection, "asiecentrale.revues.org/488", show_sigma = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.