knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of tscompare is to provide an analytics library for comparing multiple timeseries.
You can install lhe development version of tscompare from GitHub with:
# install.packages("devtools") devtools::install_github("roboton/tscompare")
This is a basic example with simulated data with two timeseries anomalies (one over and one under).
library(tscompare) set.seed(143) num_dates <- 90 num_timeseries <- 30 # generate synthetic data test_data <- setNames( merge(as.character(1:num_timeseries), seq(Sys.Date(), Sys.Date() + (num_dates - 1), by = 1), colnames = c("ts_id", "date")), c("ts_id", "date")) start_date <- Sys.Date() + floor(num_dates / 2) test_data$count <- sapply(1:(num_dates*num_timeseries), function(x) { rpois(1, 50) }) # ts anomalies test_data[test_data$ts_id == "1" & test_data$date > start_date, "count"] <- 100 test_data[test_data$ts_id == "2" & test_data$date > start_date, "count"] <- 1 output_dir <- ts_analysis( test_data, "test_analysis", start_date = start_date, period = "day", sig_p = 0.01) paste("timeseries analysis output in directory:", output_dir)
output_pngs <- list.files("test_analysis/output", pattern = ".png$") for(png in output_pngs){ cat("\n") cat("![", png, "](test_analysis/output/", png, ")", sep = "") cat("\n") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.