diff --git a/DESCRIPTION b/DESCRIPTION index e19a9bb..215da74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tibbletime Type: Package Title: Time Aware Tibbles -Version: 0.1.3.9000 +Version: 0.1.4 Authors@R: c( person("Davis", "Vaughan", email = "davis@rstudio.com", role = c("aut", "cre")), person("Matt", "Dancho", email = "mdancho@business-science.io", role = c("aut")) diff --git a/NEWS.md b/NEWS.md index 016ef88..b9ba18d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ -# tibbletime (development version) +# tibbletime 0.1.4 + +* Minor release to stay compatible with tibble 3.0.0 and the upcoming release + of dplyr 1.0.0. # tibbletime 0.1.3 diff --git a/cran-comments.md b/cran-comments.md index aeffde9..e0b104c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,11 +1,10 @@ ## Release Summary -This is a minor release of 'tibbletime'. It mainly updates the `tidyr::nest()` -and `tidyr::unnest()` methods for compatability with tidyr 1.0.0. +This is a minor release to keep tibbletime compatible with tibble and dplyr. ## Test environments -* local Mac install, R 3.6.0 -* ubuntu 14.04.5 (on travis-ci) (3.6.0, devel, release) +* local Mac install, R 4.0.0 +* ubuntu 14.04.5 (on travis-ci) (4.0.0, devel, release) * win-builder (devel and release) ## R CMD check results @@ -17,8 +16,9 @@ There were no ERRORs, WARNINGs or NOTEs. R CMD check succeeded -## Revdep checks +## revdepcheck results -The 4 revdeps have been checked, and nothing has been broken by this release. -This should free up anomalize to be fixed as well (tidyr 1.0.0 broke it). +We checked 5 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. + * We saw 0 new problems + * We failed to check 0 packages diff --git a/revdep/README.md b/revdep/README.md index 20453ac..c78502c 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -9,16 +9,14 @@ |language |(EN) | |collate |en_US.UTF-8 | |ctype |en_US.UTF-8 | -|tz |America/Los_Angeles | -|date |2019-09-19 | +|tz |America/New_York | +|date |2020-05-26 | # Dependencies -|package |old |new |Δ | -|:----------|:-----|:----------|:--| -|tibbletime |0.1.2 |0.1.2.9000 |* | -|ellipsis |NA |0.2.0.9000 |* | -|zoo |NA |1.8-6 |* | +|package |old |new |Δ | +|:----------|:-----|:-----|:--| +|tibbletime |0.1.3 |0.1.4 |* | # Revdeps diff --git a/revdep/checks.noindex/anomalize/anomalize_0.1.1.tar.gz b/revdep/checks.noindex/anomalize/anomalize_0.1.1.tar.gz deleted file mode 100644 index 853a583..0000000 Binary files a/revdep/checks.noindex/anomalize/anomalize_0.1.1.tar.gz and /dev/null differ diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/00check.log b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/00check.log index b1e8fa5..156d8e9 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/00check.log +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/00check.log @@ -5,7 +5,7 @@ * using options ‘--no-manual --no-build-vignettes’ * checking for file ‘anomalize/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘anomalize’ version ‘0.1.1’ +* this is package ‘anomalize’ version ‘0.2.0’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK @@ -16,10 +16,7 @@ * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘anomalize’ can be installed ... OK -* checking installed package size ... NOTE - installed size is 5.3Mb - sub-directories of 1Mb or more: - help 4.7Mb +* checking installed package size ... OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK @@ -61,4 +58,4 @@ * checking running R code from vignettes ... NONE * checking re-building of vignette outputs ... SKIPPED * DONE -Status: 1 NOTE +Status: OK diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.R index 15a4678..8163058 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.R @@ -61,6 +61,35 @@ gesd(x, alpha = 0.05, max_anoms = 0.2, verbose = TRUE) +cleanEx() +nameEx("clean_anomalies") +### * clean_anomalies + +flush(stderr()); flush(stdout()) + +### Name: clean_anomalies +### Title: Clean anomalies from anomalized data +### Aliases: clean_anomalies + +### ** Examples + + +library(dplyr) + +# Needed to pass CRAN check / This is loaded by default +set_time_scale_template(time_scale_template()) + +data(tidyverse_cran_downloads) + +tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + clean_anomalies() + + + + + cleanEx() nameEx("decompose_methods") ### * decompose_methods diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.Rout b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.Rout index 05c154c..a3cdcd1 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.Rout +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.Rout @@ -21,6 +21,9 @@ Type 'q()' to quit R. > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('anomalize') +══ Use anomalize to improve your Forecasts by 50%! ═════════════════════════════ +Business Science offers a 1-hour course - Lab #18: Time Series Anomaly Detection! + Learn more at: https://university.business-science.io/p/learning-labs-pro  > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') @@ -58,11 +61,6 @@ The following objects are masked from ‘package:base’: > tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` # A time tibble: 6,375 x 9 # Index: date # Groups: package [15] @@ -232,6 +230,66 @@ $outlier_report > > > cleanEx() +> nameEx("clean_anomalies") +> ### * clean_anomalies +> +> flush(stderr()); flush(stdout()) +> +> ### Name: clean_anomalies +> ### Title: Clean anomalies from anomalized data +> ### Aliases: clean_anomalies +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> # Needed to pass CRAN check / This is loaded by default +> set_time_scale_template(time_scale_template()) +> +> data(tidyverse_cran_downloads) +> +> tidyverse_cran_downloads %>% ++ time_decompose(count, method = "stl") %>% ++ anomalize(remainder, method = "iqr") %>% ++ clean_anomalies() +# A time tibble: 6,375 x 10 +# Index: date +# Groups: package [15] + package date observed season trend remainder remainder_l1 remainder_l2 +         + 1 tidyr 2017-01-01 873 -2761. 5053. -1418. -3748. 3708. + 2 tidyr 2017-01-02 1840 901. 5047. -4108. -3748. 3708. + 3 tidyr 2017-01-03 2495 1460. 5041. -4006. -3748. 3708. + 4 tidyr 2017-01-04 2906 1430. 5035. -3559. -3748. 3708. + 5 tidyr 2017-01-05 2847 1239. 5029. -3421. -3748. 3708. + 6 tidyr 2017-01-06 2756 367. 5024. -2635. -3748. 3708. + 7 tidyr 2017-01-07 1439 -2635. 5018. -944. -3748. 3708. + 8 tidyr 2017-01-08 1556 -2761. 5012. -695. -3748. 3708. + 9 tidyr 2017-01-09 3678 901. 5006. -2229. -3748. 3708. +10 tidyr 2017-01-10 7086 1460. 5000. 626. -3748. 3708. +# … with 6,365 more rows, and 2 more variables: anomaly , +# observed_cleaned  +> +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + > nameEx("decompose_methods") > ### * decompose_methods > @@ -323,7 +381,6 @@ The following objects are masked from ‘package:base’: + anomalize(remainder, method = "iqr") %>% + time_recompose() %>% + plot_anomalies(time_recomposed = TRUE) -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` frequency = 7 days trend = 91 days > @@ -334,10 +391,6 @@ trend = 91 days + anomalize(remainder, method = "iqr") %>% + time_recompose() %>% + plot_anomalies(time_recomposed = TRUE, ncol = 3) -Warning: `cols` is now required. -Please use `cols = c(nested.col)` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` > > > @@ -380,7 +433,6 @@ The following objects are masked from ‘package:base’: + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + plot_anomaly_decomposition() -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` frequency = 7 days trend = 91 days > @@ -482,9 +534,6 @@ The following objects are masked from ‘package:base’: > # Basic Usage > tidyverse_cran_downloads %>% + time_apply(count, period = "1 week", .fun = mean, na.rm = TRUE) -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` # A time tibble: 6,375 x 4 # Index: date # Groups: package [15] @@ -539,9 +588,6 @@ The following objects are masked from ‘package:base’: > # Basic Usage > tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` # A time tibble: 6,375 x 6 # Index: date # Groups: package [15] @@ -567,8 +613,6 @@ Please use `cols = c(nested.col)` + trend = "2 months", + merge = TRUE, + message = FALSE) -Warning: `cols` is now required. -Please use `cols = c(nested.col)` # A time tibble: 6,375 x 7 # Index: date # Groups: package [15] @@ -627,7 +671,6 @@ The following objects are masked from ‘package:base’: + filter(package == "tidyquant") %>% + ungroup() %>% + time_frequency(period = "auto") -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` frequency = 7 days [1] 7 > @@ -699,11 +742,6 @@ The following objects are masked from ‘package:base’: + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + time_recompose() -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` # A time tibble: 6,375 x 11 # Index: date # Groups: package [15] @@ -719,8 +757,8 @@ Please use `cols = c(nested.col)`  8 tidyr 2017-01-08 1556 -2761. 5012. -695. -3748. 3708.  9 tidyr 2017-01-09 3678 901. 5006. -2229. -3748. 3708. 10 tidyr 2017-01-10 7086 1460. 5000. 626. -3748. 3708. -# … with 6,365 more rows, and 3 more variables: anomaly , -# recomposed_l1 , recomposed_l2  +# … with 6,365 more rows, and 3 more variables: anomaly , +# recomposed_l1 , recomposed_l2  > > > @@ -766,7 +804,7 @@ detaching ‘package:dplyr’ > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 7.939 0.154 8.343 0.002 0.003 +Time elapsed: 10.053 0.208 10.304 0.001 0.002 > grDevices::dev.off() null device 1 diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.pdf b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.pdf index eee6dcd..2d8c5bc 100644 Binary files a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.pdf and b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/anomalize-Ex.pdf differ diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.R index d9866ec..f68e5a0 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.R @@ -1,9 +1,10 @@ -library(testthat) -library(anomalize) -library(dplyr) -library(ggplot2) -library(tibble) - -# set_time_scale_template(time_scale_template()) - -test_check("anomalize") +library(testthat) +library(anomalize) +library(dplyr) +library(ggplot2) +library(tibble) +library(stringr) + +# set_time_scale_template(time_scale_template()) + +test_check("anomalize") diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.Rout b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.Rout index def37b9..c6746db 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.Rout +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat.Rout @@ -17,6 +17,9 @@ Type 'q()' to quit R. > library(testthat) > library(anomalize) +══ Use anomalize to improve your Forecasts by 50%! ═════════════════════════════ +Business Science offers a 1-hour course - Lab #18: Time Series Anomaly Detection! + Learn more at: https://university.business-science.io/p/learning-labs-pro  > library(dplyr) Attaching package: 'dplyr' @@ -35,13 +38,16 @@ The following objects are masked from 'package:base': > library(ggplot2) > library(tibble) +Warning message: +package 'tibble' was built under R version 3.6.2 +> library(stringr) > > # set_time_scale_template(time_scale_template()) > > test_check("anomalize") -══ testthat results ══════════════════════════════════════════════════════════════════════════════════════════════════════ -[ OK: 64 | SKIPPED: 0 | WARNINGS: 17 | FAILED: 0 ] +══ testthat results ═══════════════════════════════════════════════════════════ +[ OK: 67 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 0 ] > > proc.time() user system elapsed - 8.106 0.184 8.317 + 14.141 0.257 14.437 diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-anomalize.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-anomalize.R index 58030d7..40ad88a 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-anomalize.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-anomalize.R @@ -1,58 +1,179 @@ -context("test-anomalize.R") - -# Setup -tq_dloads <- tidyverse_cran_downloads %>% - dplyr::ungroup() %>% - dplyr::filter(package == "tidyquant") - -# Tests - -test_that("iqr_tbl_df works", { - - iqr_tbl_df <- tq_dloads %>% - anomalize(count, method = "iqr") - - expect_equal(nrow(iqr_tbl_df), 425) - expect_equal(ncol(iqr_tbl_df), 6) - -}) - -test_that("gesd_tbl_df works", { - - gesd_tbl_df <- tq_dloads %>% - anomalize(count, method = "gesd") - - expect_equal(nrow(gesd_tbl_df), 425) - expect_equal(ncol(gesd_tbl_df), 6) - -}) - -test_that("iqr_grouped_df works", { - - iqr_grouped_df <- tidyverse_cran_downloads %>% - dplyr::ungroup() %>% - dplyr::filter(package %in% c("tidyquant", "tidytext")) %>% - dplyr::group_by(package) %>% - anomalize(count, method = "iqr") - - expect_equal(nrow(iqr_grouped_df), 850) - expect_equal(ncol(iqr_grouped_df), 6) - -}) - -test_that("gesd_grouped_df works", { - - gesd_grouped_df <- tidyverse_cran_downloads %>% - dplyr::ungroup() %>% - dplyr::filter(package %in% c("tidyquant", "tidytext")) %>% - dplyr::group_by(package) %>% - anomalize(count, method = "gesd") - - expect_equal(nrow(gesd_grouped_df), 850) - expect_equal(ncol(gesd_grouped_df), 6) - -}) - - - - +context("test-anomalize.R") + +# Setup +tq_dloads <- tidyverse_cran_downloads %>% + dplyr::ungroup() %>% + dplyr::filter(package == "tidyquant") + +# Low-variance data +low_var <- dplyr::tibble( + time = Sys.Date(), + count = c( + 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, + 0,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 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, + 1, 2, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 4, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 2, 0, 1, + 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 1, 0, 0, + 0, 2, 1, 1, 0, 0, 1, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 + ) +) %>% + mutate(time = time + row_number()) + +# Tests + +test_that("iqr_tbl_df works", { + + iqr_tbl_df <- tq_dloads %>% + anomalize(count, method = "iqr") + + expect_equal(nrow(iqr_tbl_df), 425) + expect_equal(ncol(iqr_tbl_df), 6) + +}) + +test_that("gesd_tbl_df works", { + + gesd_tbl_df <- tq_dloads %>% + anomalize(count, method = "gesd") + + expect_equal(nrow(gesd_tbl_df), 425) + expect_equal(ncol(gesd_tbl_df), 6) + +}) + +test_that("gesd can handle low variance data", { + low_var %>% + anomalize(count, method = "gesd") + + low_var %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "gesd") + + low_var %>% + time_decompose(count, method = "twitter") %>% + anomalize(remainder, method = "gesd") +}) + +test_that("iqr_grouped_df works", { + + iqr_grouped_df <- tidyverse_cran_downloads %>% + dplyr::ungroup() %>% + dplyr::filter(package %in% c("tidyquant", "tidytext")) %>% + dplyr::group_by(package) %>% + anomalize(count, method = "iqr") + + expect_equal(nrow(iqr_grouped_df), 850) + expect_equal(ncol(iqr_grouped_df), 6) + +}) + +test_that("gesd_grouped_df works", { + + gesd_grouped_df <- tidyverse_cran_downloads %>% + dplyr::ungroup() %>% + dplyr::filter(package %in% c("tidyquant", "tidytext")) %>% + dplyr::group_by(package) %>% + anomalize(count, method = "gesd") + + expect_equal(nrow(gesd_grouped_df), 850) + expect_equal(ncol(gesd_grouped_df), 6) + +}) + + + + diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomalies.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomalies.R index a31d107..4f07747 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomalies.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomalies.R @@ -1,14 +1,14 @@ -context("test-plot_anomalies.R") - -test_that("errors on incorrect input", { - expect_error(plot_anomalies(3)) -}) - -test_that("returns a ggplot", { - g <- tidyverse_cran_downloads %>% - time_decompose(count, method = "stl") %>% - anomalize(remainder, method = "iqr") %>% - time_recompose() %>% - plot_anomalies(time_recomposed = TRUE, ncol = 3) - expect_s3_class(g, "ggplot") -}) +context("test-plot_anomalies.R") + +test_that("errors on incorrect input", { + expect_error(plot_anomalies(3)) +}) + +test_that("returns a ggplot", { + g <- tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + time_recompose() %>% + plot_anomalies(time_recomposed = TRUE, ncol = 3) + expect_s3_class(g, "ggplot") +}) diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomaly_decomposition.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomaly_decomposition.R index 82d0013..9253984 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomaly_decomposition.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-plot_anomaly_decomposition.R @@ -1,18 +1,18 @@ -context("test-plot_anomaly_decomposition.R") - - - -test_that("errors on incorrect input", { - expect_error(plot_anomaly_decomposition(3)) -}) - -test_that("returns a ggplot", { - g <- tidyverse_cran_downloads %>% - filter(package == "tidyquant") %>% - ungroup() %>% - time_decompose(count, method = "stl") %>% - anomalize(remainder, method = "iqr") %>% - plot_anomaly_decomposition() - - expect_s3_class(g, "ggplot") -}) +context("test-plot_anomaly_decomposition.R") + + + +test_that("errors on incorrect input", { + expect_error(plot_anomaly_decomposition(3)) +}) + +test_that("returns a ggplot", { + g <- tidyverse_cran_downloads %>% + filter(package == "tidyquant") %>% + ungroup() %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + plot_anomaly_decomposition() + + expect_s3_class(g, "ggplot") +}) diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-prep_tbl_time.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-prep_tbl_time.R index 4044e07..f6136b0 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-prep_tbl_time.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-prep_tbl_time.R @@ -1,27 +1,27 @@ -context("test-prep_tbl_time.R") - -test_that("prep_tbl_time errors on incorrect input", { - expect_error(prep_tbl_time(1)) - expect_error(prep_tbl_time(tibble(x = stats::rnorm(100)))) -}) - -test_that("converts tibble to tbl_time", { - data_tbl <- tibble( - date = seq.Date(from = as.Date("2018-01-01"), by = "day", length.out = 10), - value = rnorm(10) - ) - - expect_s3_class(prep_tbl_time(data_tbl), class = "tbl_time") - expect_message(prep_tbl_time(data_tbl, message = T)) -}) - -test_that("tbl_time returns tbl_time", { - data_tbl <- tibble( - date = seq.Date(from = as.Date("2018-01-01"), by = "day", length.out = 10), - value = rnorm(10) - ) %>% - tibbletime::as_tbl_time(date) - - expect_s3_class(prep_tbl_time(data_tbl), class = "tbl_time") - -}) +context("test-prep_tbl_time.R") + +test_that("prep_tbl_time errors on incorrect input", { + expect_error(prep_tbl_time(1)) + expect_error(prep_tbl_time(tibble(x = stats::rnorm(100)))) +}) + +test_that("converts tibble to tbl_time", { + data_tbl <- tibble( + date = seq.Date(from = as.Date("2018-01-01"), by = "day", length.out = 10), + value = rnorm(10) + ) + + expect_s3_class(prep_tbl_time(data_tbl), class = "tbl_time") + expect_message(prep_tbl_time(data_tbl, message = T)) +}) + +test_that("tbl_time returns tbl_time", { + data_tbl <- tibble( + date = seq.Date(from = as.Date("2018-01-01"), by = "day", length.out = 10), + value = rnorm(10) + ) %>% + tibbletime::as_tbl_time(date) + + expect_s3_class(prep_tbl_time(data_tbl), class = "tbl_time") + +}) diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_apply.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_apply.R index 8533885..bedc5ff 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_apply.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_apply.R @@ -1,23 +1,23 @@ -context("test-time_apply.R") - - -test_that("errors on incorrect input", { - expect_error(time_apply(2)) - expect_error(tidyverse_cran_downloads %>% time_apply()) -}) - - -test_that("grouped_tbl_time works", { - grouped_tbl_time_mean <- tidyverse_cran_downloads %>% - time_apply(count, period = "1 week", .fun = mean, na.rm = TRUE) - expect_equal(ncol(grouped_tbl_time_mean), 4) -}) - -test_that("tbl_time works", { - grouped_tbl_time_mean <- tidyverse_cran_downloads %>% - filter(package == "tidyquant") %>% - ungroup() %>% - time_apply(count, period = "1 week", .fun = mean, na.rm = TRUE) - expect_equal(ncol(grouped_tbl_time_mean), 4) -}) - +context("test-time_apply.R") + + +test_that("errors on incorrect input", { + expect_error(time_apply(2)) + expect_error(tidyverse_cran_downloads %>% time_apply()) +}) + + +test_that("grouped_tbl_time works", { + grouped_tbl_time_mean <- tidyverse_cran_downloads %>% + time_apply(count, period = "1 week", .fun = mean, na.rm = TRUE) + expect_equal(ncol(grouped_tbl_time_mean), 4) +}) + +test_that("tbl_time works", { + grouped_tbl_time_mean <- tidyverse_cran_downloads %>% + filter(package == "tidyquant") %>% + ungroup() %>% + time_apply(count, period = "1 week", .fun = mean, na.rm = TRUE) + expect_equal(ncol(grouped_tbl_time_mean), 4) +}) + diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_decompose.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_decompose.R index 4f2074b..d795323 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_decompose.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_decompose.R @@ -1,134 +1,134 @@ -context("test-time_decompose.R") - - -test_that("Incorrect data type errors", { - expect_error(time_decompose(5)) -}) - -test_that("No target errors", { - expect_error(time_decompose(tidyverse_cran_downloads)) - expect_error(time_decompose(ungroup(tidyverse_cran_downloads))) -}) - -test_that("single tbl_df", { - stl_tbl_time <- tidyverse_cran_downloads %>% - filter(package == "lubridate") %>% - ungroup() %>% - as.tibble() %>% - time_decompose(count, method = "stl", frequency = "auto", trend = "auto") - - expect_equal(ncol(stl_tbl_time), 5) - expect_equal(nrow(stl_tbl_time), 425) - -}) - -test_that("grouped tbl_df", { - stl_tbl_time <- tidyverse_cran_downloads %>% - as.tibble() %>% - time_decompose(count, method = "stl", frequency = "auto", trend = "auto") - - expect_equal(ncol(stl_tbl_time), 6) - expect_equal(nrow(stl_tbl_time), 6375) - -}) - -test_that("method = stl, auto freq/trend", { - stl_tbl_time <- tidyverse_cran_downloads %>% - time_decompose(count, method = "stl", frequency = "auto", trend = "auto") - - expect_equal(ncol(stl_tbl_time), 6) - expect_equal(nrow(stl_tbl_time), 6375) - expect_equal(group_size(stl_tbl_time) %>% length(), 15) - -}) - -test_that("method = stl, character freq/trend", { - stl_tbl_time <- tidyverse_cran_downloads %>% - time_decompose(count, method = "stl", frequency = "1 month", trend = "3 months") - - expect_equal(ncol(stl_tbl_time), 6) - expect_equal(nrow(stl_tbl_time), 6375) - expect_equal(group_size(stl_tbl_time) %>% length(), 15) - -}) - -test_that("method = stl, numeric freq/trend", { - stl_tbl_time <- tidyverse_cran_downloads %>% - time_decompose(count, method = "stl", frequency = 7, trend = 30) - - expect_equal(ncol(stl_tbl_time), 6) - expect_equal(nrow(stl_tbl_time), 6375) - expect_equal(group_size(stl_tbl_time) %>% length(), 15) - -}) - -test_that("method = twitter, auto freq/trend", { - twitter_tbl_time <- tidyverse_cran_downloads %>% - time_decompose(count, method = "twitter", frequency = "auto", trend = "auto") - - expect_equal(ncol(twitter_tbl_time), 6) - expect_equal(nrow(twitter_tbl_time), 6375) - expect_equal(group_size(twitter_tbl_time) %>% length(), 15) - -}) - -test_that("method = twitter, character freq/trend", { - twitter_tbl_time <- tidyverse_cran_downloads %>% - time_decompose(count, method = "twitter", frequency = "1 week", trend = "1 month") - - expect_equal(ncol(twitter_tbl_time), 6) - expect_equal(nrow(twitter_tbl_time), 6375) - expect_equal(group_size(twitter_tbl_time) %>% length(), 15) - -}) - -test_that("method = twitter, numeric freq/trend", { - twitter_tbl_time <- tidyverse_cran_downloads %>% - time_decompose(count, method = "twitter", frequency = 7, trend = 90) - - expect_equal(ncol(twitter_tbl_time), 6) - expect_equal(nrow(twitter_tbl_time), 6375) - expect_equal(group_size(twitter_tbl_time) %>% length(), 15) - -}) - -# test_that("method = multiplicative, auto freq/trend", { -# mult_tbl_time <- tidyverse_cran_downloads %>% -# time_decompose(count, method = "multiplicative", frequency = "auto", trend = "auto") -# -# expect_equal(ncol(mult_tbl_time), 6) -# expect_equal(nrow(mult_tbl_time), 6375) -# expect_equal(group_size(mult_tbl_time) %>% length(), 15) -# -# }) -# -# test_that("method = multiplicative, character freq/trend", { -# mult_tbl_time <- tidyverse_cran_downloads %>% -# time_decompose(count, method = "multiplicative", frequency = "1 week", trend = "1 month") -# -# expect_equal(ncol(mult_tbl_time), 6) -# expect_equal(nrow(mult_tbl_time), 6375) -# expect_equal(group_size(mult_tbl_time) %>% length(), 15) -# -# }) -# -# test_that("method = multiplicative, numeric freq/trend", { -# mult_tbl_time <- tidyverse_cran_downloads %>% -# time_decompose(count, method = "multiplicative", frequency = 7, trend = 90) -# -# expect_equal(ncol(mult_tbl_time), 6) -# expect_equal(nrow(mult_tbl_time), 6375) -# expect_equal(group_size(mult_tbl_time) %>% length(), 15) -# -# }) - -test_that("grouped_df works", { - grouped_data <- tidyverse_cran_downloads %>% - as.tibble() %>% - time_decompose(count) - - expect_equal(ncol(grouped_data), 6) - expect_equal(nrow(grouped_data), 6375) - expect_equal(group_size(grouped_data) %>% length(), 15) - -}) +context("test-time_decompose.R") + + +test_that("Incorrect data type errors", { + expect_error(time_decompose(5)) +}) + +test_that("No target errors", { + expect_error(time_decompose(tidyverse_cran_downloads)) + expect_error(time_decompose(ungroup(tidyverse_cran_downloads))) +}) + +test_that("single tbl_df", { + stl_tbl_time <- tidyverse_cran_downloads %>% + filter(package == "lubridate") %>% + ungroup() %>% + as_tibble() %>% + time_decompose(count, method = "stl", frequency = "auto", trend = "auto") + + expect_equal(ncol(stl_tbl_time), 5) + expect_equal(nrow(stl_tbl_time), 425) + +}) + +test_that("grouped tbl_df", { + stl_tbl_time <- tidyverse_cran_downloads %>% + as_tibble() %>% + time_decompose(count, method = "stl", frequency = "auto", trend = "auto") + + expect_equal(ncol(stl_tbl_time), 6) + expect_equal(nrow(stl_tbl_time), 6375) + +}) + +test_that("method = stl, auto freq/trend", { + stl_tbl_time <- tidyverse_cran_downloads %>% + time_decompose(count, method = "stl", frequency = "auto", trend = "auto") + + expect_equal(ncol(stl_tbl_time), 6) + expect_equal(nrow(stl_tbl_time), 6375) + expect_equal(group_size(stl_tbl_time) %>% length(), 15) + +}) + +test_that("method = stl, character freq/trend", { + stl_tbl_time <- tidyverse_cran_downloads %>% + time_decompose(count, method = "stl", frequency = "1 month", trend = "3 months") + + expect_equal(ncol(stl_tbl_time), 6) + expect_equal(nrow(stl_tbl_time), 6375) + expect_equal(group_size(stl_tbl_time) %>% length(), 15) + +}) + +test_that("method = stl, numeric freq/trend", { + stl_tbl_time <- tidyverse_cran_downloads %>% + time_decompose(count, method = "stl", frequency = 7, trend = 30) + + expect_equal(ncol(stl_tbl_time), 6) + expect_equal(nrow(stl_tbl_time), 6375) + expect_equal(group_size(stl_tbl_time) %>% length(), 15) + +}) + +test_that("method = twitter, auto freq/trend", { + twitter_tbl_time <- tidyverse_cran_downloads %>% + time_decompose(count, method = "twitter", frequency = "auto", trend = "auto") + + expect_equal(ncol(twitter_tbl_time), 6) + expect_equal(nrow(twitter_tbl_time), 6375) + expect_equal(group_size(twitter_tbl_time) %>% length(), 15) + +}) + +test_that("method = twitter, character freq/trend", { + twitter_tbl_time <- tidyverse_cran_downloads %>% + time_decompose(count, method = "twitter", frequency = "1 week", trend = "1 month") + + expect_equal(ncol(twitter_tbl_time), 6) + expect_equal(nrow(twitter_tbl_time), 6375) + expect_equal(group_size(twitter_tbl_time) %>% length(), 15) + +}) + +test_that("method = twitter, numeric freq/trend", { + twitter_tbl_time <- tidyverse_cran_downloads %>% + time_decompose(count, method = "twitter", frequency = 7, trend = 90) + + expect_equal(ncol(twitter_tbl_time), 6) + expect_equal(nrow(twitter_tbl_time), 6375) + expect_equal(group_size(twitter_tbl_time) %>% length(), 15) + +}) + +# test_that("method = multiplicative, auto freq/trend", { +# mult_tbl_time <- tidyverse_cran_downloads %>% +# time_decompose(count, method = "multiplicative", frequency = "auto", trend = "auto") +# +# expect_equal(ncol(mult_tbl_time), 6) +# expect_equal(nrow(mult_tbl_time), 6375) +# expect_equal(group_size(mult_tbl_time) %>% length(), 15) +# +# }) +# +# test_that("method = multiplicative, character freq/trend", { +# mult_tbl_time <- tidyverse_cran_downloads %>% +# time_decompose(count, method = "multiplicative", frequency = "1 week", trend = "1 month") +# +# expect_equal(ncol(mult_tbl_time), 6) +# expect_equal(nrow(mult_tbl_time), 6375) +# expect_equal(group_size(mult_tbl_time) %>% length(), 15) +# +# }) +# +# test_that("method = multiplicative, numeric freq/trend", { +# mult_tbl_time <- tidyverse_cran_downloads %>% +# time_decompose(count, method = "multiplicative", frequency = 7, trend = 90) +# +# expect_equal(ncol(mult_tbl_time), 6) +# expect_equal(nrow(mult_tbl_time), 6375) +# expect_equal(group_size(mult_tbl_time) %>% length(), 15) +# +# }) + +test_that("grouped_df works", { + grouped_data <- tidyverse_cran_downloads %>% + as_tibble() %>% + time_decompose(count) + + expect_equal(ncol(grouped_data), 6) + expect_equal(nrow(grouped_data), 6375) + expect_equal(group_size(grouped_data) %>% length(), 15) + +}) diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_frequency.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_frequency.R index 86185e9..c3ab90e 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_frequency.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_frequency.R @@ -1,88 +1,88 @@ -context("test-time_frequency.R") - -# Setup - -tq_dloads <- tidyverse_cran_downloads %>% - ungroup() %>% - filter(package == "tidyquant") - -tq_dloads_small <- tq_dloads %>% - slice(1:60) - -# Tests - -test_that("time_frequency fails with incorrect input", { - expect_error(time_frequency(5)) - expect_error(time_frequency(tidyverse_cran_downloads)) -}) - -test_that("time_trend fails with incorrect input", { - expect_error(time_trend(5)) - expect_error(time_trend(tidyverse_cran_downloads)) -}) - -test_that("time_frequency works: period = 'auto'", { - - freq <- tq_dloads %>% - time_frequency() - - expect_equal(freq, 7) - -}) - -test_that("time_frequency works: period = '1 month'", { - - freq <- tq_dloads %>% - time_frequency(period = "1 month") - - expect_equal(freq, 31) - -}) - -test_that("time_frequency works: period = 5", { - - freq <- tq_dloads %>% - time_frequency(period = 5) - - expect_equal(freq, 5) - -}) - - - -test_that("time_trend works: period = 'auto'", { - - trend <- tq_dloads %>% - time_trend() - - expect_equal(trend, 91) - -}) - -test_that("time_trend works: period = '90 days'", { - - trend <- tq_dloads %>% - time_trend(period = "30 days") - - expect_equal(trend, 30) - -}) - -test_that("time_trend works: period = 90", { - - trend <- tq_dloads %>% - time_trend(period = 90) - - expect_equal(trend, 90) - -}) - -test_that("time_trend works with small data: period = 'auto'", { - - trend <- tq_dloads_small %>% - time_trend() - - expect_equal(trend, 28) - -}) - +context("test-time_frequency.R") + +# Setup + +tq_dloads <- tidyverse_cran_downloads %>% + ungroup() %>% + filter(package == "tidyquant") + +tq_dloads_small <- tq_dloads %>% + slice(1:60) + +# Tests + +test_that("time_frequency fails with incorrect input", { + expect_error(time_frequency(5)) + expect_error(time_frequency(tidyverse_cran_downloads)) +}) + +test_that("time_trend fails with incorrect input", { + expect_error(time_trend(5)) + expect_error(time_trend(tidyverse_cran_downloads)) +}) + +test_that("time_frequency works: period = 'auto'", { + + freq <- tq_dloads %>% + time_frequency() + + expect_equal(freq, 7) + +}) + +test_that("time_frequency works: period = '1 month'", { + + freq <- tq_dloads %>% + time_frequency(period = "1 month") + + expect_equal(freq, 31) + +}) + +test_that("time_frequency works: period = 5", { + + freq <- tq_dloads %>% + time_frequency(period = 5) + + expect_equal(freq, 5) + +}) + + + +test_that("time_trend works: period = 'auto'", { + + trend <- tq_dloads %>% + time_trend() + + expect_equal(trend, 91) + +}) + +test_that("time_trend works: period = '90 days'", { + + trend <- tq_dloads %>% + time_trend(period = "30 days") + + expect_equal(trend, 30) + +}) + +test_that("time_trend works: period = 90", { + + trend <- tq_dloads %>% + time_trend(period = 90) + + expect_equal(trend, 90) + +}) + +test_that("time_trend works with small data: period = 'auto'", { + + trend <- tq_dloads_small %>% + time_trend() + + expect_equal(trend, 28) + +}) + diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_recompose.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_recompose.R index cd99867..7491430 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_recompose.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-time_recompose.R @@ -1,25 +1,25 @@ -context("test-time_recompose.R") - - -test_that("errors on incorrect input", { - expect_error(time_recompose(5)) -}) - -test_that("time_recompose works on grouped_tbl_time", { - grouped_recomp <- tidyverse_cran_downloads %>% - time_decompose(count, method = "stl") %>% - anomalize(remainder, method = "iqr") %>% - time_recompose() - expect_true("recomposed_l2" %in% names(grouped_recomp)) -}) - -test_that("time_recompose works on tbl_time", { - single_recomp <- tidyverse_cran_downloads %>% - filter(package == "tidyquant") %>% - ungroup() %>% - time_decompose(count, method = "stl") %>% - anomalize(remainder, method = "iqr") %>% - time_recompose() - expect_true("recomposed_l2" %in% names(single_recomp)) -}) - +context("test-time_recompose.R") + + +test_that("errors on incorrect input", { + expect_error(time_recompose(5)) +}) + +test_that("time_recompose works on grouped_tbl_time", { + grouped_recomp <- tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + time_recompose() + expect_true("recomposed_l2" %in% names(grouped_recomp)) +}) + +test_that("time_recompose works on tbl_time", { + single_recomp <- tidyverse_cran_downloads %>% + filter(package == "tidyquant") %>% + ungroup() %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + time_recompose() + expect_true("recomposed_l2" %in% names(single_recomp)) +}) + diff --git a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-utils.R b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-utils.R index 0d40ea3..66f0611 100644 --- a/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-utils.R +++ b/revdep/checks.noindex/anomalize/new/anomalize.Rcheck/tests/testthat/test-utils.R @@ -1,7 +1,7 @@ -context("test-utils.R") - -test_that("utils: time_decompose `merge = T` works", { - merged_decomposition <- tidyverse_cran_downloads %>% - time_decompose(count, merge = T) - expect_equal(ncol(merged_decomposition), 7) -}) +context("test-utils.R") + +test_that("utils: time_decompose `merge = T` works", { + merged_decomposition <- tidyverse_cran_downloads %>% + time_decompose(count, merge = T) + expect_equal(ncol(merged_decomposition), 7) +}) diff --git a/revdep/checks.noindex/anomalize/new/libraries.txt b/revdep/checks.noindex/anomalize/new/libraries.txt index 97e189a..e39954d 100644 --- a/revdep/checks.noindex/anomalize/new/libraries.txt +++ b/revdep/checks.noindex/anomalize/new/libraries.txt @@ -1,145 +1,164 @@ Library: /Users/davis/Desktop/r/packages/tibbletime/revdep/library.noindex/tibbletime/new -ellipsis (0.2.0.9000) -tibbletime (0.1.2.9000) -zoo (1.8-6) +tibbletime (0.1.4) Library: /Users/davis/Desktop/r/packages/tibbletime/revdep/library.noindex/anomalize +alphavantager (0.1.2) askpass (1.1) assertthat (0.2.1) -backports (1.1.4) +backports (1.1.7) base64enc (0.1-3) -BH (1.69.0-1) +BH (1.72.0-3) brew (1.0-6) -broom (0.5.2) -callr (3.3.1) +broom (0.5.6) +callr (3.4.3) cellranger (1.1.0) -cli (1.1.0) +class (7.3-17) +cli (2.0.2) clipr (0.7.0) -clisymbols (1.2.0) +codetools (0.2-16) colorspace (1.4-1) commonmark (1.7) -covr (3.3.1) +covr (3.5.0) crayon (1.3.4) -crosstalk (1.0.0) -curl (4.1) -DBI (1.0.0) -dbplyr (1.4.2) +crosstalk (1.1.0.1) +curl (4.3) +data.table (1.12.8) +DBI (1.1.0) +dbplyr (1.4.3) desc (1.2.0) -devtools (2.2.0) -digest (0.6.20) -dplyr (0.8.3) -DT (0.9) -ellipsis (0.2.0.1) +devtools (2.3.0) +digest (0.6.25) +dplyr (0.8.5) +DT (0.13) +ellipsis (0.3.1) evaluate (0.14) -fansi (0.4.0) -forcats (0.4.0) -forecast (8.9) -fracdiff (1.4-2) -fs (1.3.1) +fansi (0.4.1) +farver (2.0.3) +forcats (0.5.0) +forecast (8.12) +fracdiff (1.5-1) +fs (1.4.1) +furrr (0.1.0) +future (1.17.0) generics (0.0.2) -ggplot2 (3.2.1) -gh (1.0.1) -git2r (0.26.1) -glue (1.3.1) +ggplot2 (3.3.0) +gh (1.1.0) +git2r (0.27.1) +globals (0.12.5) +glue (1.4.1) +gower (0.2.1) gtable (0.3.0) -haven (2.1.1) +haven (2.3.0) +hexbin (1.28.1) highr (0.8) -hms (0.5.1) -htmltools (0.3.6) -htmlwidgets (1.3) -httpuv (1.5.2) +hms (0.5.3) +htmltools (0.4.0) +htmlwidgets (1.5.1) httr (1.4.1) ini (0.3.1) -jsonlite (1.6) -knitr (1.25) +ipred (0.9-9) +isoband (0.2.1) +jsonlite (1.6.1) +KernSmooth (2.23-17) +knitr (1.28) labeling (0.3) -later (0.8.0) -lattice (0.20-38) +later (1.0.0) +lattice (0.20-41) +lava (1.6.7) lazyeval (0.2.2) -lifecycle (0.1.0) +lifecycle (0.2.0) +listenv (0.8.0) lmtest (0.9-37) -lubridate (1.7.4) +lubridate (1.7.8) magrittr (1.5) markdown (1.1) -MASS (7.3-51.4) -Matrix (1.2-17) +MASS (7.3-51.6) +Matrix (1.2-18) memoise (1.1.0) -mgcv (1.8-28) -mime (0.7) -modelr (0.1.5) +mgcv (1.8-31) +mime (0.9) +modelr (0.1.8) munsell (0.5.0) -nlme (3.1-141) -nnet (7.3-12) +nlme (3.1-148) +nnet (7.3-14) +numDeriv (2016.8-1.1) openssl (1.4.1) -padr (0.5.0) -PerformanceAnalytics (1.5.3) -pillar (1.4.2) -pkgbuild (1.0.5) -pkgconfig (2.0.2) +padr (0.5.2) +PerformanceAnalytics (2.0.4) +pillar (1.4.4) +pkgbuild (1.0.8) +pkgconfig (2.0.3) pkgload (1.0.2) plogr (0.2.0) -plyr (1.8.4) +plotly (4.9.2.1) +plyr (1.8.6) praise (1.0.0) -prettyunits (1.0.2) -processx (3.4.1) +prettyunits (1.1.1) +processx (3.4.2) +prodlim (2019.11.13) progress (1.2.2) -promises (1.0.1) -ps (1.3.0) -purrr (0.3.2) -quadprog (1.5-7) +promises (1.1.0) +ps (1.3.3) +purrr (0.3.4) +quadprog (1.5-8) Quandl (2.10.0) -quantmod (0.4-15) -R6 (2.4.0) +quantmod (0.4.17) +R6 (2.4.1) rcmdcheck (1.3.3) RColorBrewer (1.1-2) -Rcpp (1.0.2) -RcppArmadillo (0.9.700.2.0) +Rcpp (1.0.4) +RcppArmadillo (0.9.880.1.0) readr (1.3.1) readxl (1.3.1) +recipes (0.1.12) rematch (1.0.1) -remotes (2.1.0) +rematch2 (2.1.2) +remotes (2.1.1) reprex (0.3.0) -reshape2 (1.4.3) -rex (1.1.2) -rlang (0.4.0) -rmarkdown (1.15) -roxygen2 (6.1.1) +reshape2 (1.4.4) +rex (1.2.0) +riingo (0.2.0) +rlang (0.4.6) +rmarkdown (2.1) +roxygen2 (7.1.0) +rpart (4.1-15) rprojroot (1.3-2) -rstudioapi (0.10) -rversions (2.0.0) -rvest (0.3.4) -scales (1.0.0) -selectr (0.4-1) +rsample (0.0.6) +rstudioapi (0.11) +rversions (2.0.2) +rvest (0.3.5) +scales (1.1.1) +selectr (0.4-2) sessioninfo (1.1.1) -shiny (1.3.2) -sourcetools (0.1.7) -stringi (1.4.3) +slider (0.1.3) +SQUAREM (2020.2) +stringi (1.4.6) stringr (1.4.0) -sweep (0.2.1.1) +survival (3.1-12) +sweep (0.2.2) sys (3.3) -testthat (2.2.1) -tibble (2.1.3) -tidyquant (0.5.6) -tidyr (1.0.0) -tidyselect (0.2.5) -tidyverse (1.2.1) +testthat (2.3.2) +tibble (3.0.1) +tidyquant (1.0.0) +tidyr (1.1.0) +tidyselect (1.1.0) +tidyverse (1.3.0) timeDate (3043.102) -timetk (0.1.1.1) -tinytex (0.16) +timetk (1.0.0) +tinytex (0.23) tseries (0.10-47) -TTR (0.23-4) +TTR (0.23-6) urca (1.3-0) -usethis (1.5.1) +usethis (1.6.1) utf8 (1.1.4) -vctrs (0.2.0) +vctrs (0.3.0) viridisLite (0.3.0) +warp (0.1.0) whisker (0.4) -withr (2.1.2) -xfun (0.9) -xml2 (1.2.2) +withr (2.2.0) +xfun (0.14) +xml2 (1.3.2) xopen (1.0.0) -xtable (1.8-4) -xts (0.11-2) -yaml (2.2.0) -zeallot (0.1.0) -zoo (1.8-6) +xts (0.12-0) +yaml (2.2.1) +zoo (1.8-8) diff --git a/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/00check.log b/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/00check.log index ce062b5..59f1a0e 100644 --- a/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/00check.log +++ b/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/00check.log @@ -5,7 +5,7 @@ * using options ‘--no-manual --no-build-vignettes’ * checking for file ‘anomalize/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘anomalize’ version ‘0.1.1’ +* this is package ‘anomalize’ version ‘0.2.0’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK @@ -16,10 +16,7 @@ * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘anomalize’ can be installed ... OK -* checking installed package size ... NOTE - installed size is 5.3Mb - sub-directories of 1Mb or more: - help 4.7Mb +* checking installed package size ... OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK @@ -52,67 +49,13 @@ * checking data for ASCII and uncompressed saves ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK -* checking examples ... ERROR -Running examples in ‘anomalize-Ex.R’ failed -The error most likely occurred in: - -> ### Name: anomalize -> ### Title: Detect anomalies using the tidyverse -> ### Aliases: anomalize -> -> ### ** Examples -> -> -> library(dplyr) - -Attaching package: ‘dplyr’ - -The following objects are masked from ‘package:stats’: - - filter, lag - -The following objects are masked from ‘package:base’: - - intersect, setdiff, setequal, union - -> -> # Needed to pass CRAN check / This is loaded by default -> set_time_scale_template(time_scale_template()) -> -> data(tidyverse_cran_downloads) -> -> tidyverse_cran_downloads %>% -+ time_decompose(count, method = "stl") %>% -+ anomalize(remainder, method = "iqr") -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` -Error in !.key : invalid argument type -Calls: %>% ... -> nest.grouped_df -> check_key -> is_missing -Execution halted +* checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK -* checking tests ... ERROR +* checking tests ... OK Running ‘testthat.R’ -Running the tests in ‘tests/testthat.R’ failed. -Last 13 lines of output: - ══ testthat results ══════════════════════════════════════════════════════════════════════════════════════════════════════ - [ OK: 33 | SKIPPED: 0 | WARNINGS: 1 | FAILED: 14 ] - 1. Error: iqr_grouped_df works (@test-anomalize.R#32) - 2. Error: gesd_grouped_df works (@test-anomalize.R#45) - 3. Error: returns a ggplot (@test-plot_anomalies.R#8) - 4. Error: grouped_tbl_time works (@test-time_apply.R#11) - 5. Error: grouped tbl_df (@test-time_decompose.R#26) - 6. Error: method = stl, auto freq/trend (@test-time_decompose.R#36) - 7. Error: method = stl, character freq/trend (@test-time_decompose.R#46) - 8. Error: method = stl, numeric freq/trend (@test-time_decompose.R#56) - 9. Error: method = twitter, auto freq/trend (@test-time_decompose.R#66) - 1. ... - - Error: testthat unit tests failed - Execution halted * checking for unstated dependencies in vignettes ... OK * checking package vignettes in ‘inst/doc’ ... OK * checking running R code from vignettes ... NONE * checking re-building of vignette outputs ... SKIPPED * DONE -Status: 2 ERRORs, 1 NOTE +Status: OK diff --git a/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.R b/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.R index 15a4678..8163058 100644 --- a/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.R +++ b/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.R @@ -61,6 +61,35 @@ gesd(x, alpha = 0.05, max_anoms = 0.2, verbose = TRUE) +cleanEx() +nameEx("clean_anomalies") +### * clean_anomalies + +flush(stderr()); flush(stdout()) + +### Name: clean_anomalies +### Title: Clean anomalies from anomalized data +### Aliases: clean_anomalies + +### ** Examples + + +library(dplyr) + +# Needed to pass CRAN check / This is loaded by default +set_time_scale_template(time_scale_template()) + +data(tidyverse_cran_downloads) + +tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") %>% + clean_anomalies() + + + + + cleanEx() nameEx("decompose_methods") ### * decompose_methods diff --git a/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.Rout b/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.Rout index 33d3bdb..c345a65 100644 --- a/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.Rout +++ b/revdep/checks.noindex/anomalize/old/anomalize.Rcheck/anomalize-Ex.Rout @@ -21,6 +21,9 @@ Type 'q()' to quit R. > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('anomalize') +══ Use anomalize to improve your Forecasts by 50%! ═════════════════════════════ +Business Science offers a 1-hour course - Lab #18: Time Series Anomaly Detection! + Learn more at: https://university.business-science.io/p/learning-labs-pro  > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') @@ -58,9 +61,756 @@ The following objects are masked from ‘package:base’: > tidyverse_cran_downloads %>% + time_decompose(count, method = "stl") %>% + anomalize(remainder, method = "iqr") -Warning: Detecting old grouped_df format, replacing `vars` attribute by `groups` -Warning: `cols` is now required. -Please use `cols = c(nested.col)` -Error in !.key : invalid argument type -Calls: %>% ... -> nest.grouped_df -> check_key -> is_missing -Execution halted +# A time tibble: 6,375 x 9 +# Index: date +# Groups: package [15] + package date observed season trend remainder remainder_l1 remainder_l2 +         + 1 tidyr 2017-01-01 873 -2761. 5053. -1418. -3748. 3708. + 2 tidyr 2017-01-02 1840 901. 5047. -4108. -3748. 3708. + 3 tidyr 2017-01-03 2495 1460. 5041. -4006. -3748. 3708. + 4 tidyr 2017-01-04 2906 1430. 5035. -3559. -3748. 3708. + 5 tidyr 2017-01-05 2847 1239. 5029. -3421. -3748. 3708. + 6 tidyr 2017-01-06 2756 367. 5024. -2635. -3748. 3708. + 7 tidyr 2017-01-07 1439 -2635. 5018. -944. -3748. 3708. + 8 tidyr 2017-01-08 1556 -2761. 5012. -695. -3748. 3708. + 9 tidyr 2017-01-09 3678 901. 5006. -2229. -3748. 3708. +10 tidyr 2017-01-10 7086 1460. 5000. 626. -3748. 3708. +# … with 6,365 more rows, and 1 more variable: anomaly  +> +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("anomalize_methods") +> ### * anomalize_methods +> +> flush(stderr()); flush(stdout()) +> +> ### Name: anomalize_methods +> ### Title: Methods that power anomalize() +> ### Aliases: anomalize_methods iqr gesd +> +> ### ** Examples +> +> +> set.seed(100) +> x <- rnorm(100) +> idx_outliers <- sample(100, size = 5) +> x[idx_outliers] <- x[idx_outliers] + 10 +> +> iqr(x, alpha = 0.05, max_anoms = 0.2) + [1] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [13] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [25] "No" "No" "No" "No" "No" "Yes" "No" "No" "No" "No" "No" "No" + [37] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [49] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [61] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" + [73] "No" "Yes" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" "No" + [85] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [97] "Yes" "No" "No" "No" +> iqr(x, alpha = 0.05, max_anoms = 0.2, verbose = TRUE) +$outlier + [1] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [13] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [25] "No" "No" "No" "No" "No" "Yes" "No" "No" "No" "No" "No" "No" + [37] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [49] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [61] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" + [73] "No" "Yes" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" "No" + [85] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [97] "Yes" "No" "No" "No" + +$outlier_idx +[1] 74 71 30 82 97 + +$outlier_vals +[1] 11.648522 10.448903 10.247076 9.950004 9.167504 + +$outlier_direction +[1] "Up" "Up" "Up" "Up" "Up" + +$critical_limits +limit_lower limit_upper + -4.552347 4.755455 + +$outlier_report +# A tibble: 20 x 7 + rank index value limit_lower limit_upper outlier direction +        + 1 1 74 11.6 -4.55 4.76 Yes Up + 2 2 71 10.4 -4.55 4.76 Yes Up + 3 3 30 10.2 -4.55 4.76 Yes Up + 4 4 82 9.95 -4.55 4.76 Yes Up + 5 5 97 9.17 -4.55 4.76 Yes Up + 6 6 64 2.58 -4.55 4.76 No NA + 7 7 55 -2.27 -4.55 4.76 No NA + 8 8 96 2.45 -4.55 4.76 No NA + 9 9 20 2.31 -4.55 4.76 No NA +10 10 80 -2.07 -4.55 4.76 No NA +11 11 75 -2.06 -4.55 4.76 No NA +12 12 84 -1.93 -4.55 4.76 No NA +13 13 50 -1.88 -4.55 4.76 No NA +14 14 43 -1.78 -4.55 4.76 No NA +15 15 52 -1.74 -4.55 4.76 No NA +16 16 54 1.90 -4.55 4.76 No NA +17 17 58 1.82 -4.55 4.76 No NA +18 18 32 1.76 -4.55 4.76 No NA +19 19 89 1.73 -4.55 4.76 No NA +20 20 57 -1.40 -4.55 4.76 No NA + +> +> gesd(x, alpha = 0.05, max_anoms = 0.2) + [1] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [13] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [25] "No" "No" "No" "No" "No" "Yes" "No" "No" "No" "No" "No" "No" + [37] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [49] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [61] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" + [73] "No" "Yes" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" "No" + [85] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [97] "Yes" "No" "No" "No" +> gesd(x, alpha = 0.05, max_anoms = 0.2, verbose = TRUE) +$outlier + [1] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [13] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [25] "No" "No" "No" "No" "No" "Yes" "No" "No" "No" "No" "No" "No" + [37] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [49] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [61] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" + [73] "No" "Yes" "No" "No" "No" "No" "No" "No" "No" "Yes" "No" "No" + [85] "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" "No" + [97] "Yes" "No" "No" "No" + +$outlier_idx +[1] 74 71 30 82 97 + +$outlier_vals +[1] 11.648522 10.448903 10.247076 9.950004 9.167504 + +$outlier_direction +[1] "Up" "Up" "Up" "Up" "Up" + +$critical_limits +limit_lower limit_upper + -3.31569 3.31569 + +$outlier_report +# A tibble: 20 x 7 + rank index value limit_lower limit_upper outlier direction +        + 1 1 74 11.6 -3.60 3.60 Yes Up + 2 2 71 10.4 -3.49 3.49 Yes Up + 3 3 30 10.2 -3.45 3.45 Yes Up + 4 4 82 9.95 -3.53 3.53 Yes Up + 5 5 97 9.17 -3.42 3.42 Yes Up + 6 6 64 2.58 -3.32 3.32 No NA + 7 7 96 2.45 -3.28 3.28 No NA + 8 8 20 2.31 -3.24 3.24 No NA + 9 9 55 -2.27 -3.15 3.15 No NA +10 10 80 -2.07 -3.12 3.12 No NA +11 11 75 -2.06 -3.05 3.05 No NA +12 12 54 1.90 -2.95 2.95 No NA +13 13 58 1.82 -2.78 2.78 No NA +14 14 84 -1.93 -2.57 2.57 No NA +15 15 32 1.76 -2.54 2.54 No NA +16 16 89 1.73 -2.53 2.53 No NA +17 17 50 -1.88 -2.54 2.54 No NA +18 18 43 -1.78 -2.50 2.50 No NA +19 19 52 -1.74 -2.46 2.46 No NA +20 20 92 1.43 -2.44 2.44 No NA + +> +> +> +> +> +> cleanEx() +> nameEx("clean_anomalies") +> ### * clean_anomalies +> +> flush(stderr()); flush(stdout()) +> +> ### Name: clean_anomalies +> ### Title: Clean anomalies from anomalized data +> ### Aliases: clean_anomalies +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> # Needed to pass CRAN check / This is loaded by default +> set_time_scale_template(time_scale_template()) +> +> data(tidyverse_cran_downloads) +> +> tidyverse_cran_downloads %>% ++ time_decompose(count, method = "stl") %>% ++ anomalize(remainder, method = "iqr") %>% ++ clean_anomalies() +# A time tibble: 6,375 x 10 +# Index: date +# Groups: package [15] + package date observed season trend remainder remainder_l1 remainder_l2 +         + 1 tidyr 2017-01-01 873 -2761. 5053. -1418. -3748. 3708. + 2 tidyr 2017-01-02 1840 901. 5047. -4108. -3748. 3708. + 3 tidyr 2017-01-03 2495 1460. 5041. -4006. -3748. 3708. + 4 tidyr 2017-01-04 2906 1430. 5035. -3559. -3748. 3708. + 5 tidyr 2017-01-05 2847 1239. 5029. -3421. -3748. 3708. + 6 tidyr 2017-01-06 2756 367. 5024. -2635. -3748. 3708. + 7 tidyr 2017-01-07 1439 -2635. 5018. -944. -3748. 3708. + 8 tidyr 2017-01-08 1556 -2761. 5012. -695. -3748. 3708. + 9 tidyr 2017-01-09 3678 901. 5006. -2229. -3748. 3708. +10 tidyr 2017-01-10 7086 1460. 5000. 626. -3748. 3708. +# … with 6,365 more rows, and 2 more variables: anomaly , +# observed_cleaned  +> +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("decompose_methods") +> ### * decompose_methods +> +> flush(stderr()); flush(stdout()) +> +> ### Name: decompose_methods +> ### Title: Methods that power time_decompose() +> ### Aliases: decompose_methods decompose_twitter decompose_stl +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> tidyverse_cran_downloads %>% ++ ungroup() %>% ++ filter(package == "tidyquant") %>% ++ decompose_stl(count) +frequency = 7 days +trend = 91 days +# A time tibble: 425 x 5 +# Index: date + date observed season trend remainder +      + 1 2017-01-01 9 -19.8 27.3 1.46 + 2 2017-01-02 55 12.4 27.4 15.2 + 3 2017-01-03 48 11.3 27.4 9.28 + 4 2017-01-04 25 8.91 27.4 -11.4 + 5 2017-01-05 22 9.80 27.5 -15.3 + 6 2017-01-06 7.00 -1.26 27.5 -19.3 + 7 2017-01-07 7 -21.3 27.5 0.807 + 8 2017-01-08 32 -19.8 27.6 24.2 + 9 2017-01-09 70 12.4 27.6 30.0 +10 2017-01-10 33 11.3 27.6 -5.95 +# … with 415 more rows +> +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("plot_anomalies") +> ### * plot_anomalies +> +> flush(stderr()); flush(stdout()) +> +> ### Name: plot_anomalies +> ### Title: Visualize the anomalies in one or multiple time series +> ### Aliases: plot_anomalies +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> library(ggplot2) +> +> data(tidyverse_cran_downloads) +> +> #### SINGLE TIME SERIES #### +> tidyverse_cran_downloads %>% ++ filter(package == "tidyquant") %>% ++ ungroup() %>% ++ time_decompose(count, method = "stl") %>% ++ anomalize(remainder, method = "iqr") %>% ++ time_recompose() %>% ++ plot_anomalies(time_recomposed = TRUE) +frequency = 7 days +trend = 91 days +> +> +> #### MULTIPLE TIME SERIES #### +> tidyverse_cran_downloads %>% ++ time_decompose(count, method = "stl") %>% ++ anomalize(remainder, method = "iqr") %>% ++ time_recompose() %>% ++ plot_anomalies(time_recomposed = TRUE, ncol = 3) +> +> +> +> +> cleanEx() + +detaching ‘package:ggplot2’, ‘package:dplyr’ + +> nameEx("plot_anomaly_decomposition") +> ### * plot_anomaly_decomposition +> +> flush(stderr()); flush(stdout()) +> +> ### Name: plot_anomaly_decomposition +> ### Title: Visualize the time series decomposition with anomalies shown +> ### Aliases: plot_anomaly_decomposition +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> library(ggplot2) +> +> data(tidyverse_cran_downloads) +> +> tidyverse_cran_downloads %>% ++ filter(package == "tidyquant") %>% ++ ungroup() %>% ++ time_decompose(count, method = "stl") %>% ++ anomalize(remainder, method = "iqr") %>% ++ plot_anomaly_decomposition() +frequency = 7 days +trend = 91 days +> +> +> +> +> cleanEx() + +detaching ‘package:ggplot2’, ‘package:dplyr’ + +> nameEx("prep_tbl_time") +> ### * prep_tbl_time +> +> flush(stderr()); flush(stdout()) +> +> ### Name: prep_tbl_time +> ### Title: Automatically create tibbletime objects from tibbles +> ### Aliases: prep_tbl_time +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> library(tibbletime) + +Attaching package: ‘tibbletime’ + +The following object is masked from ‘package:stats’: + + filter + +> +> data_tbl <- tibble( ++ date = seq.Date(from = as.Date("2018-01-01"), by = "day", length.out = 10), ++ value = rnorm(10) ++ ) +> +> prep_tbl_time(data_tbl) +# A time tibble: 10 x 2 +# Index: date + date value +   + 1 2018-01-01 -0.626 + 2 2018-01-02 0.184 + 3 2018-01-03 -0.836 + 4 2018-01-04 1.60 + 5 2018-01-05 0.330 + 6 2018-01-06 -0.820 + 7 2018-01-07 0.487 + 8 2018-01-08 0.738 + 9 2018-01-09 0.576 +10 2018-01-10 -0.305 +> +> +> +> +> cleanEx() + +detaching ‘package:tibbletime’, ‘package:dplyr’ + +> nameEx("time_apply") +> ### * time_apply +> +> flush(stderr()); flush(stdout()) +> +> ### Name: time_apply +> ### Title: Apply a function to a time series by period +> ### Aliases: time_apply +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> data(tidyverse_cran_downloads) +> +> # Basic Usage +> tidyverse_cran_downloads %>% ++ time_apply(count, period = "1 week", .fun = mean, na.rm = TRUE) +# A time tibble: 6,375 x 4 +# Index: date +# Groups: package [15] + package date count time_apply +     + 1 tidyr 2017-01-01 873 2165. + 2 tidyr 2017-01-02 1840 2165. + 3 tidyr 2017-01-03 2495 2165. + 4 tidyr 2017-01-04 2906 2165. + 5 tidyr 2017-01-05 2847 2165. + 6 tidyr 2017-01-06 2756 2165. + 7 tidyr 2017-01-07 1439 2165. + 8 tidyr 2017-01-08 1556 4058. + 9 tidyr 2017-01-09 3678 4058. +10 tidyr 2017-01-10 7086 4058. +# … with 6,365 more rows +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("time_decompose") +> ### * time_decompose +> +> flush(stderr()); flush(stdout()) +> +> ### Name: time_decompose +> ### Title: Decompose a time series in preparation for anomaly detection +> ### Aliases: time_decompose +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> data(tidyverse_cran_downloads) +> +> # Basic Usage +> tidyverse_cran_downloads %>% ++ time_decompose(count, method = "stl") +# A time tibble: 6,375 x 6 +# Index: date +# Groups: package [15] + package date observed season trend remainder +       + 1 tidyr 2017-01-01 873 -2761. 5053. -1418. + 2 tidyr 2017-01-02 1840 901. 5047. -4108. + 3 tidyr 2017-01-03 2495 1460. 5041. -4006. + 4 tidyr 2017-01-04 2906 1430. 5035. -3559. + 5 tidyr 2017-01-05 2847 1239. 5029. -3421. + 6 tidyr 2017-01-06 2756 367. 5024. -2635. + 7 tidyr 2017-01-07 1439 -2635. 5018. -944. + 8 tidyr 2017-01-08 1556 -2761. 5012. -695. + 9 tidyr 2017-01-09 3678 901. 5006. -2229. +10 tidyr 2017-01-10 7086 1460. 5000. 626. +# … with 6,365 more rows +> +> # twitter +> tidyverse_cran_downloads %>% ++ time_decompose(count, ++ method = "twitter", ++ frequency = "1 week", ++ trend = "2 months", ++ merge = TRUE, ++ message = FALSE) +# A time tibble: 6,375 x 7 +# Index: date +# Groups: package [15] + package date count observed season median_spans remainder +        + 1 tidyr 2017-01-01 873 873 -2619. 5297 -1805. + 2 tidyr 2017-01-02 1840 1840 891. 5297 -4348. + 3 tidyr 2017-01-03 2495 2495 1409. 5297 -4211. + 4 tidyr 2017-01-04 2906 2906 1346. 5297 -3737. + 5 tidyr 2017-01-05 2847 2847 1199. 5297 -3649. + 6 tidyr 2017-01-06 2756 2756 247. 5297 -2788. + 7 tidyr 2017-01-07 1439 1439 -2472. 5297 -1386. + 8 tidyr 2017-01-08 1556 1556. -2619. 5297 -1122. + 9 tidyr 2017-01-09 3678 3678 891. 5297 -2510. +10 tidyr 2017-01-10 7086 7086 1409. 5297 380. +# … with 6,365 more rows +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("time_frequency") +> ### * time_frequency +> +> flush(stderr()); flush(stdout()) +> +> ### Name: time_frequency +> ### Title: Generate a time series frequency from a periodicity +> ### Aliases: time_frequency time_trend +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> data(tidyverse_cran_downloads) +> +> #### FREQUENCY DETECTION #### +> +> # period = "auto" +> tidyverse_cran_downloads %>% ++ filter(package == "tidyquant") %>% ++ ungroup() %>% ++ time_frequency(period = "auto") +frequency = 7 days +[1] 7 +> +> time_scale_template() +# A tibble: 8 x 3 + time_scale frequency trend +    +1 second 1 hour 12 hours +2 minute 1 day 14 days +3 hour 1 day 1 month +4 day 1 week 3 months +5 week 1 quarter 1 year +6 month 1 year 5 years +7 quarter 1 year 10 years +8 year 5 years 30 years +> +> # period = "1 month" +> tidyverse_cran_downloads %>% ++ filter(package == "tidyquant") %>% ++ ungroup() %>% ++ time_frequency(period = "1 month") +frequency = 31 days +[1] 31 +> +> #### TREND DETECTION #### +> +> tidyverse_cran_downloads %>% ++ filter(package == "tidyquant") %>% ++ ungroup() %>% ++ time_trend(period = "auto") +trend = 91 days +[1] 91 +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("time_recompose") +> ### * time_recompose +> +> flush(stderr()); flush(stdout()) +> +> ### Name: time_recompose +> ### Title: Recompose bands separating anomalies from "normal" observations +> ### Aliases: time_recompose +> +> ### ** Examples +> +> +> library(dplyr) + +Attaching package: ‘dplyr’ + +The following objects are masked from ‘package:stats’: + + filter, lag + +The following objects are masked from ‘package:base’: + + intersect, setdiff, setequal, union + +> +> data(tidyverse_cran_downloads) +> +> # Basic Usage +> tidyverse_cran_downloads %>% ++ time_decompose(count, method = "stl") %>% ++ anomalize(remainder, method = "iqr") %>% ++ time_recompose() +# A time tibble: 6,375 x 11 +# Index: date +# Groups: package [15] + package date observed season trend remainder remainder_l1 remainder_l2 +         + 1 tidyr 2017-01-01 873 -2761. 5053. -1418. -3748. 3708. + 2 tidyr 2017-01-02 1840 901. 5047. -4108. -3748. 3708. + 3 tidyr 2017-01-03 2495 1460. 5041. -4006. -3748. 3708. + 4 tidyr 2017-01-04 2906 1430. 5035. -3559. -3748. 3708. + 5 tidyr 2017-01-05 2847 1239. 5029. -3421. -3748. 3708. + 6 tidyr 2017-01-06 2756 367. 5024. -2635. -3748. 3708. + 7 tidyr 2017-01-07 1439 -2635. 5018. -944. -3748. 3708. + 8 tidyr 2017-01-08 1556 -2761. 5012. -695. -3748. 3708. + 9 tidyr 2017-01-09 3678 901. 5006. -2229. -3748. 3708. +10 tidyr 2017-01-10 7086 1460. 5000. 626. -3748. 3708. +# … with 6,365 more rows, and 3 more variables: anomaly , +# recomposed_l1 , recomposed_l2  +> +> +> +> +> +> cleanEx() + +detaching ‘package:dplyr’ + +> nameEx("time_scale_template") +> ### * time_scale_template +> +> flush(stderr()); flush(stdout()) +> +> ### Name: set_time_scale_template +> ### Title: Get and modify time scale template +> ### Aliases: set_time_scale_template get_time_scale_template +> ### time_scale_template +> +> ### ** Examples +> +> +> get_time_scale_template() +# A tibble: 8 x 3 + time_scale frequency trend +    +1 second 1 hour 12 hours +2 minute 1 day 14 days +3 hour 1 day 1 month +4 day 1 week 3 months +5 week 1 quarter 1 year +6 month 1 year 5 years +7 quarter 1 year 10 years +8 year 5 years 30 years +> +> set_time_scale_template(time_scale_template()) +> +> +> +> +> ### *