business-science / anomalize

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

Can the messages in time_decompose be suppressed in a tidy way? #28

Open DaveParr opened 5 years ago

DaveParr commented 5 years ago

Thanks for the work on the package, I've mostly been finding it really useful, apart from the following issue.

The following from the example prints a large volume of output to the console:

suppressMessages(library(tibbletime))
suppressMessages(library(anomalize))

tidyverse_cran_downloads_anomalized <- tidyverse_cran_downloads %>%
time_decompose(count, merge = TRUE, message = FALSE)

The output:

Registered S3 method overwritten by 'xts':
  method     from
  as.zoo.xts zoo 
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Registered S3 methods overwritten by 'forecast':
  method             from    
  fitted.fracdiff    fracdiff
  residuals.fracdiff fracdiff
Warning message:
Detecting old grouped_df format, replacing `vars` attribute by `groups` 

The S3 overwrite warnings are generated at the execution of time_decompose, not at the library call. This makes the output frustrating when you aware of these operations, but you can't turn them off.

What would be the recommendation to prevent these messages printing to console?

DaveParr commented 5 years ago

So I've found a workaround:

You can call:

suppressMessages(library(tibbletime))
suppressMessages(library(anomalize))
suppressMessages(library(forecast))

By forcing the library load pre-emptively and then controlling the messaging at that stage, the package is already attached, and therefore time_decompose doesn't generate the messages.

forecast seems (right now), to cover all bases: forecast, quantmod and xts.