Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gg_season() shows wrong values on x-axis #107

Closed
karabanb opened this issue Jun 21, 2020 · 4 comments
Closed

gg_season() shows wrong values on x-axis #107

karabanb opened this issue Jun 21, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@karabanb
Copy link

karabanb commented Jun 21, 2020

When I try plot examples from with fpp3 book with gg_season (without period argument) plots has unwanted and wrong years on x-axis.

All examples with declared period argument works well.

library(fpp3)

a10 <- PBS %>% 
  filter(ATC2=='A10') %>% 
  select(Month, Concession, Type, Cost) %>% 
  summarise(TotalC = sum(Cost)) %>% 
  mutate(Cost = TotalC/1e6)

a10 %>% 
  gg_season(Cost, labels = 'both') +
  ylab('$ milion') +
  ggtitle('Seasonal plot: antidiabetic drug sales')

example

sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/pl_PL.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] fable_0.2.1       feasts_0.1.4      fabletools_0.2.0  tsibbledata_0.2.0 tsibble_0.9.1    
 [6] ggplot2_3.3.2     lubridate_1.7.9   tidyr_1.1.0       dplyr_1.0.0       tibble_3.0.1     
[11] fpp3_0.3         

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6         pillar_1.4.4         compiler_4.0.0       tools_4.0.0         
 [5] digest_0.6.25        lifecycle_0.2.0      gtable_0.3.0         anytime_0.3.7       
 [9] pkgconfig_2.0.3      rlang_0.4.6          cli_2.0.2            rstudioapi_0.11     
[13] xfun_0.15            withr_2.2.0          generics_0.0.2       vctrs_0.3.1         
[17] hms_0.5.3            grid_4.0.0           tidyselect_1.1.0     glue_1.4.1          
[21] R6_2.4.1             fansi_0.4.1          distributional_0.1.0 farver_2.0.3        
[25] readr_1.3.1          purrr_0.3.4          magrittr_1.5         scales_1.1.1        
[29] ellipsis_0.3.1       assertthat_0.2.1     colorspace_1.4-1     renv_0.10.0         
[33] labeling_0.3         utf8_1.1.4           tinytex_0.24         munsell_0.5.0       
[37] crayon_1.3.4
@mitchelloharawild mitchelloharawild added the bug Something isn't working label Jun 21, 2020
@mitchelloharawild mitchelloharawild self-assigned this Jun 21, 2020
@regisely
Copy link

regisely commented Jul 2, 2020

Similar problem with gg_subseries:

library(dplyr)
library(tsibble)
library(feasts)

tourism %>%
  group_by(Purpose) %>%
  summarise(Trips = sum(Trips), .groups = "drop") %>%
  gg_subseries(Trips)

@mitchelloharawild
Copy link
Member

mitchelloharawild commented Aug 8, 2020

Should work now, thanks for the issue and patience!
This issue was introduced updating to support vctrs and the plot functions were updated to preserve time classes. For now, I've converted it to dates as the tsibble time classes do not have ggplot date-style labelling support.

gg_season()

library(fpp3)

a10 <- PBS %>% 
  filter(ATC2=='A10') %>% 
  select(Month, Concession, Type, Cost) %>% 
  summarise(TotalC = sum(Cost)) %>% 
  mutate(Cost = TotalC/1e6)

a10 %>% 
  gg_season(Cost, labels = 'both') +
  ylab('$ milion') +
  ggtitle('Seasonal plot: antidiabetic drug sales')

Created on 2020-08-08 by the reprex package (v0.3.0)

gg_subseries()

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(tsibble)
library(feasts)
#> Loading required package: fabletools

tourism %>%
  group_by(Purpose) %>%
  summarise(Trips = sum(Trips), .groups = "drop") %>%
  gg_subseries(Trips)

Created on 2020-08-08 by the reprex package (v0.3.0)

@baletercero
Copy link

baletercero commented Aug 13, 2020

I reinstalled feasts (version 0.1.4 ), the issue remains, do I have to install a different version of feasts / fpp3 ? Many thanks

@mitchelloharawild
Copy link
Member

mitchelloharawild commented Aug 14, 2020

This is fixed in the development version of the package which is not yet on CRAN.
You can install it with remotes::install_github("tidyverts/feasts")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants