tsbox icon indicating copy to clipboard operation
tsbox copied to clipboard

Silence messages

Open pollytatouin opened this issue 2 years ago • 2 comments

Hi,

I was wondering if there was a way to silence the messages that popout when using different tsbox functions ([value]:...)? I searched in the docs and older issues but could not find an answer.

It's mostly esthetics, but when running loops for multiple series it quickly makes the console filled completely.

Thank you for your support and this wonderful package, Polly

suppressWarnings(suppressPackageStartupMessages(require(tsbox)))
suppressWarnings(suppressPackageStartupMessages(require(dplyr)))

data.frame(time = seq.Date(as.Date("2020-01-01"), as.Date("2022-12-01"), by = "month"),
           y = rnorm(36)) %>% 
  ts_frequency("quarter")
#> [value]: 'y' 
#> [value]: 'y' 
#> [value]: 'y'
#>          time           y
#> 1  2020-01-01 -0.77409211
#> 2  2020-04-01 -0.22029236
#> 3  2020-07-01  0.09998298
#> 4  2020-10-01 -0.01518559
#> 5  2021-01-01 -0.04929204
#> 6  2021-04-01 -0.89451864
#> 7  2021-07-01 -0.53612993
#> 8  2021-10-01 -0.78087768
#> 9  2022-01-01  0.06620837
#> 10 2022-04-01  0.28651782
#> 11 2022-07-01 -0.35354366
#> 12 2022-10-01 -0.37939443

sessionInfo()
#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19043)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=French_Canada.1252  LC_CTYPE=French_Canada.1252   
#> [3] LC_MONETARY=French_Canada.1252 LC_NUMERIC=C                  
#> [5] LC_TIME=French_Canada.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] dplyr_1.0.7 tsbox_0.3.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.7        compiler_4.1.0    pillar_1.7.0      highr_0.9        
#>  [5] tools_4.1.0       digest_0.6.28     evaluate_0.15     lifecycle_1.0.0  
#>  [9] tibble_3.1.7      anytime_0.3.9     pkgconfig_2.0.3   rlang_1.0.2      
#> [13] reprex_2.0.1      cli_3.3.0         DBI_1.1.1         rstudioapi_0.13  
#> [17] yaml_2.3.5        xfun_0.30         fastmap_1.1.0     withr_2.5.0      
#> [21] stringr_1.4.0     knitr_1.38        generics_0.1.2    fs_1.5.2         
#> [25] vctrs_0.4.1       tidyselect_1.1.1  glue_1.6.2        data.table_1.14.2
#> [29] R6_2.5.0          fansi_0.5.0       rmarkdown_2.13    purrr_0.3.4      
#> [33] magrittr_2.0.1    htmltools_0.5.2   ellipsis_0.3.2    assertthat_0.2.1 
#> [37] utf8_1.2.2        stringi_1.7.4     crayon_1.4.1

Created on 2022-07-21 by the reprex package (v2.0.1)

pollytatouin avatar Jul 21 '22 16:07 pollytatouin

Thanks! There is currently no option to silence the messages, but I guess it would make sense to have something like that.

Plus, it could be more intelligent and return the same message only once.

You can now use ts_default() to change the column names to the defaults. No message would be generated in subsequent calls:

library(tsbox)

data.frame(
  time = seq.Date(as.Date("2020-01-01"), as.Date("2022-12-01"), by = "month"),
  y = rnorm(36)
) |> 
  ts_default() |> 
  ts_frequency("quarter")
#> [value]: 'y'
#>          time        value
#> 1  2020-01-01  0.361538405
#> 2  2020-04-01  1.148143131
#> 3  2020-07-01 -0.419883427
#> 4  2020-10-01  0.170981391
#> 5  2021-01-01  1.105875046
#> 6  2021-04-01  0.382514026
#> 7  2021-07-01 -0.425736839
#> 8  2021-10-01 -0.716303278
#> 9  2022-01-01 -0.117076296
#> 10 2022-04-01  0.003476006
#> 11 2022-07-01  0.144177237
#> 12 2022-10-01  0.710708008

christophsax avatar Aug 24 '22 01:08 christophsax

Ah okay that's good to know. I'm not sure it would always be a solution though, for instance with loops over N different dataframes: we'd still get N messages.

Again, really not a huge deal, I just thought it'd be simple to silence(?)

pollytatouin avatar Aug 24 '22 17:08 pollytatouin