From bd5d46a26c6c07b8c48f5c8151db62fa82f1eafb Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 10 Dec 2024 16:00:39 +0000 Subject: [PATCH] Update seasonal_rain.R --- R/seasonal_rain.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/R/seasonal_rain.R b/R/seasonal_rain.R index 2195857..32c8e07 100644 --- a/R/seasonal_rain.R +++ b/R/seasonal_rain.R @@ -143,11 +143,12 @@ seasonal_rain <- function (summary_data = NULL, start_date = NULL, end_date = NU } if(!is.null(s_start_doy)){ # any(grepl("-", summary_data[[year]]))){ - data <- shift_dates(data = data, date = "date", s_start_doy = s_start_doy - 1) - year <- "year" - doy <- "doy" - data[[year]] <- data[["s_year"]] + # The shifting has already happened in R-Instat + #data <- shift_dates(data = data, date = date_time, s_start_doy = s_start_doy - 1) + year <- "s_year" + doy <- "s_doy" data[[doy]] <- data[["s_doy"]] + data[[year]] <- data[["s_year"]] } data[[year]] <- factor(data[[year]]) summary_data <- dplyr::full_join(data %>% dplyr::select(c({{ station }}, {{ year }}, {{ date_time }}, @@ -179,4 +180,4 @@ seasonal_rain <- function (summary_data = NULL, start_date = NULL, end_date = NU if (total_rain) climatic_output <- climatic_output %>% dplyr::rename(seasonal_rain = total_rain) if (n_rain) climatic_output <- climatic_output %>% dplyr::rename(n_seasonal_rain = n_rain) return(climatic_output) -} \ No newline at end of file +}