From 8b9528e38749e78a35cb14f7c57ce5de84a7d404 Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Thu, 26 Sep 2024 08:33:53 +1000 Subject: [PATCH] Fix removal of monthday and yearday gg_season wrap formats --- NEWS.md | 4 ++++ R/graphics.R | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9e099acb..522bbb43 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # feasts (development version) +## Bug fixes + +* Fixed `gg_season()` not working with daily data showing seasonality > 1 week. + # feasts 0.4.0 ## New features diff --git a/R/graphics.R b/R/graphics.R index b500ca7b..299eac86 100644 --- a/R/graphics.R +++ b/R/graphics.R @@ -75,10 +75,10 @@ time_identifier <- function(idx, period, base = NULL, within = NULL, interval){ if(interval >= months(1)){ formats <- formats[c("Month", "Year", "Yearmonth", "Date")] } else if (interval >= lubridate::weeks(1)){ - formats <- formats[c("Monthday", "Yearday", "Week", "Month", "Year", + formats <- formats[c("Week", "Month", "Year", "Yearweek", "Yearmonth", "Date")] } else if (interval >= lubridate::days(1)){ - formats <- formats[c("Weekday", "Monthday", "Yearday", "Week", "Month", "Year", + formats <- formats[c("Weekday", "Week", "Month", "Year", "Yearweek", "Yearmonth", "Date")] } } @@ -181,13 +181,13 @@ guess_plot_var <- function(x, y){ #' @param data A tidy time series object (tsibble) #' @param y The variable to plot (a bare expression). If NULL, it will #' automatically selected from the data. -#' @param period The seasonal period to display. If NULL (default), -#' the largest frequency in the data is used. If numeric, it represents -#' the frequency times the interval between observations. If a string -#' (e.g., "1y" for 1 year, "3m" for 3 months, "1d" for 1 day, -#' "1h" for 1 hour, "1min" for 1 minute, "1s" for 1 second), -#' it's converted to a Period class object from the lubridate package. -#' Note that the data must have at least one observation per seasonal period, +#' @param period The seasonal period to display. If NULL (default), +#' the largest frequency in the data is used. If numeric, it represents +#' the frequency times the interval between observations. If a string +#' (e.g., "1y" for 1 year, "3m" for 3 months, "1d" for 1 day, +#' "1h" for 1 hour, "1min" for 1 minute, "1s" for 1 second), +#' it's converted to a Period class object from the lubridate package. +#' Note that the data must have at least one observation per seasonal period, #' and the period cannot be smaller than the observation interval. #' @param facet_period A secondary seasonal period to facet by #' (typically smaller than period).