tidyverts / feasts

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

Preserve order of factors in gg_season() and gg_suberies() #165

Open pasahe opened 4 months ago

pasahe commented 4 months ago

Hello,

Facets created when using gg_season() and gg_subseries() on a tsibble with a factor in its keys are not ordered on the levels of the factor. Here is some reproducible code based on the example documentation of gg_subseries()

tsibbledata::aus_retail |> 
  filter(
    Industry == "Cafes, restaurants and catering services"
  ) |> 
  mutate(
    State = forcats::fct_infreq(State)
  ) |>
  gg_subseries(Turnover)

I have reordered the State variable based on the frequency of its values, but the facets are still ordered alphabetically ignoring the order of the levels.

Thank you very much!