tidyverts / feasts

Feature Extraction And Statistics for Time Series
https://feasts.tidyverts.org/
295 stars 23 forks source link

gg_subseries() error when index column name has spaces #136

Closed heiku-jiqu closed 3 years ago

heiku-jiqu commented 3 years ago

Hello,

I am getting an error with gg_subseries when my tsibble's index column is named with spaces, e.g. Year Month. There's an error message saying "Don't know how to automatically pick scale for object of type NULL. Defaulting to continuous", which seems to stem from the expr_text() in the line below.

https://github.com/tidyverts/feasts/blob/dc8e588b216f27a8cfced9b4393f6daaf3c886ed/R/graphics.R#L437

Maybe using as_name() or as_label() instead of expr_text() will help?

mitchelloharawild commented 3 years ago

MRE:

library(feasts)
#> Loading required package: fabletools
library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, union
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
tourism %>% 
  summarise(Trips = sum(Trips)) %>% 
  rename(`index with spaces` = Quarter) %>% 
  gg_subseries()
#> Plot variable not specified, automatically selected `y = Trips`
#> Don't know how to automatically pick scale for object of type NULL. Defaulting to continuous.
#> Error in get(scale_fn, asNamespace("feasts"), mode = "function"): object 'scale_x_continuous' of mode 'function' was not found

Created on 2021-05-06 by the reprex package (v1.0.0)

mitchelloharawild commented 3 years ago

Fixed, thanks!

library(feasts)
#> Loading required package: fabletools
library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, union
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
tourism %>% 
  summarise(Trips = sum(Trips)) %>% 
  rename(`index with spaces` = Quarter) %>% 
  gg_subseries()
#> Plot variable not specified, automatically selected `y = Trips`

Created on 2021-05-06 by the reprex package (v1.0.0)