I want the mean and median month of the date columns:

> library(dplyr)
> 
> summarize_data <- function(data) {
+   # Step 1: Summarize main data
+   summarized_data <- data %>%
+     select(Dates, Week, DEC_BASIS, PEO_BASIS, ESL_BASIS, FUT_1, FUT_2, Year, Crop_Progression) %>%
+     group_by(Year) %>%
+     reframe(
+       across(c(DEC_BASIS, PEO_BASIS, ESL_BASIS, FUT_1, FUT_2, Crop_Progression),
+              list(
+                min = ~ifelse(all(is.na(.)), NA, min(., na.rm = TRUE)),
+                max = ~ifelse(all(is.na(.)), NA, max(., na.rm = TRUE)),
+                week_min = ~ifelse(all(is.na(.)), NA, Week[which.min(.)]),
+                week_max = ~ifelse(all(is.na(.)), NA, Week[which.max(.)])
+              ),
+              .names = "{.col}_{.fn}"),
+       
+       DEC_BASIS_date_min = as.Date(ifelse(all(is.na(DEC_BASIS)), NA, Dates[which.min(DEC_BASIS)])),
+       DEC_BASIS_date_max = as.Date(ifelse(all(is.na(DEC_BASIS)), NA, Dates[which.max(DEC_BASIS)])),
+       PEO_BASIS_date_min = as.Date(ifelse(all(is.na(PEO_BASIS)), NA, Dates[which.min(PEO_BASIS)])),
+       PEO_BASIS_date_max = as.Date(ifelse(all(is.na(PEO_BASIS)), NA, Dates[which.max(PEO_BASIS)])),
+       ESL_BASIS_date_min = as.Date(ifelse(all(is.na(ESL_BASIS)), NA, Dates[which.min(ESL_BASIS)])),
+       ESL_BASIS_date_max = as.Date(ifelse(all(is.na(ESL_BASIS)), NA, Dates[which.max(ESL_BASIS)])),
+       FUT_1_date_min = as.Date(ifelse(all(is.na(FUT_1)), NA, Dates[which.min(FUT_1)])),
+       FUT_1_date_max = as.Date(ifelse(all(is.na(FUT_1)), NA, Dates[which.max(FUT_1)])),
+       FUT_2_date_min = as.Date(ifelse(all(is.na(FUT_2)), NA, Dates[which.min(FUT_2)])),
+       FUT_2_date_max = as.Date(ifelse(all(is.na(FUT_2)), NA, Dates[which.max(FUT_2)])),
+       Crop_Progression_date_min = as.Date(ifelse(all(is.na(Crop_Progression)), NA, Dates[which.min(Crop_Progression)])),
+       Crop_Progression_date_max = as.Date(ifelse(all(is.na(Crop_Progression)), NA, Dates[which.max(Crop_Progression)]))
+     ) %>%
+     select(
+       Year,
+       DEC_BASIS_min, DEC_BASIS_week_min, DEC_BASIS_date_min, DEC_BASIS_max, DEC_BASIS_week_max, DEC_BASIS_date_max,
+       PEO_BASIS_min, PEO_BASIS_week_min, PEO_BASIS_date_min, PEO_BASIS_max, PEO_BASIS_week_max, PEO_BASIS_date_max,
+       ESL_BASIS_min, ESL_BASIS_week_min, ESL_BASIS_date_min, ESL_BASIS_max, ESL_BASIS_week_max, ESL_BASIS_date_max,
+       FUT_1_min, FUT_1_week_min, FUT_1_date_min, FUT_1_max, FUT_1_week_max, FUT_1_date_max,
+       FUT_2_min, FUT_2_week_min, FUT_2_date_min, FUT_2_max, FUT_2_week_max, FUT_2_date_max,
+       Crop_Progression_min, Crop_Progression_week_min, Crop_Progression_date_min, Crop_Progression_max, Crop_Progression_week_max, Crop_Progression_date_max
+     ) %>%
+     mutate(Year = as.character(Year))  # Convert Year to character
+   
+   print(str(summarized_data))
+   
+   # Step 2: Create mean row for numeric columns
+   mean_row <- summarized_data %>%
+     summarize(across(where(is.numeric), ~ mean(., na.rm = TRUE))) %>%
+     mutate(across(where(~ !is.numeric(.)), ~ NA)) %>%
+     mutate(Year = "Mean")  # Set Year as "Mean" for identification
+   
+   # Step 3: Create median row for numeric columns
+   median_row <- summarized_data %>%
+     summarize(across(where(is.numeric), ~ median(., na.rm = TRUE))) %>%
+     mutate(across(where(~ !is.numeric(.)), ~ NA)) %>%
+     mutate(Year = "Median")  # Set Year as "Median" for identification
+   
+   # Step 4: Bind the mean and median rows to the main summarized data
+   bind_rows(summarized_data, mean_row, median_row)
+ }
> 
> # Apply function and view results
> Yearly_min_max <- summarize_data(Weekly_Corn_Data)
tibble [20 × 37] (S3: tbl_df/tbl/data.frame)
 $ Year                     : chr [1:20] "2005" "2006" "2007" "2008" ...
 $ DEC_BASIS_min            : num [1:20] -0.27 -0.23 -0.35 -0.32 -0.16 -0.15 -0.13 0 -0.11 -0.28 ...
 $ DEC_BASIS_week_min       : num [1:20] 39 21 37 27 52 36 10 49 41 41 ...
 $ DEC_BASIS_date_min       : Date[1:20], format: "2005-09-30" "2006-05-26" "2007-09-14" "2008-07-04" ...
 $ DEC_BASIS_max            : num [1:20] 0.05 0.13 0.09 0.01 0.19 0.12 0.5 0.7 1.89 0.4 ...
 $ DEC_BASIS_week_max       : num [1:20] 6 47 48 48 36 47 28 27 27 35 ...
 $ DEC_BASIS_date_max       : Date[1:20], format: "2005-02-11" "2006-11-24" "2007-11-30" "2008-11-28" ...
 $ PEO_BASIS_min            : num [1:20] -0.27 -0.26 -0.39 -0.55 -0.3 -0.38 -0.2 0.03 -0.04 -0.25 ...
 $ PEO_BASIS_week_min       : num [1:20] 42 20 37 27 51 31 9 51 49 42 ...
 $ PEO_BASIS_date_min       : Date[1:20], format: "2005-10-21" "2006-05-19" "2007-09-14" "2008-07-04" ...
 $ PEO_BASIS_max            : num [1:20] 0.03 0.03 0.04 -0.15 0.16 0.02 0.33 0.71 1.99 0.32 ...
 $ PEO_BASIS_week_max       : num [1:20] 47 47 48 52 36 12 29 24 27 35 ...
 $ PEO_BASIS_date_max       : Date[1:20], format: "2005-11-25" "2006-11-24" "2007-11-30" "2008-12-26" ...
 $ ESL_BASIS_min            : num [1:20] -0.49 -0.17 -0.39 -0.54 -0.4 -0.4 -0.21 -0.45 -0.15 -0.46 ...
 $ ESL_BASIS_week_min       : num [1:20] 39 28 34 44 52 53 3 48 1 40 ...
 $ ESL_BASIS_date_min       : Date[1:20], format: "2005-09-30" "2006-07-14" "2007-08-24" "2008-10-31" ...
 $ ESL_BASIS_max            : num [1:20] 0.19 0.16 0.16 -0.01 0.25 0.18 0.5 0.73 1.76 0.4 ...
 $ ESL_BASIS_week_max       : num [1:20] 13 47 44 5 33 16 28 27 27 30 ...
 $ ESL_BASIS_date_max       : Date[1:20], format: "2005-04-01" "2006-11-24" "2007-11-02" "2008-02-01" ...
 $ FUT_1_min                : num [1:20] 1.9 2.05 3.18 2.94 3 ...
 $ FUT_1_week_min           : num [1:20] 49 3 29 49 36 22 47 22 48 39 ...
 $ FUT_1_date_min           : Date[1:20], format: "2005-12-09" "2006-01-20" "2007-07-20" "2008-12-05" ...
 $ FUT_1_max                : num [1:20] 2.58 3.9 4.52 7.55 4.44 ...
 $ FUT_1_week_max           : num [1:20] 28 52 52 26 23 52 23 29 5 17 ...
 $ FUT_1_date_max           : Date[1:20], format: "2005-07-15" "2006-12-29" "2007-12-28" "2008-06-27" ...
 $ FUT_2_min                : num [1:20] 2.03 2.15 3.33 3.09 3.06 ...
 $ FUT_2_week_min           : num [1:20] 47 3 29 49 36 22 47 24 48 39 ...
 $ FUT_2_date_min           : Date[1:20], format: "2005-11-25" "2006-01-20" "2007-07-20" "2008-12-05" ...
 $ FUT_2_max                : num [1:20] 2.68 3.98 4.63 7.68 4.54 ...
 $ FUT_2_week_max           : num [1:20] 28 52 52 26 23 52 14 32 5 17 ...
 $ FUT_2_date_max           : Date[1:20], format: "2005-07-15" "2006-12-29" "2007-12-28" "2008-06-27" ...
 $ Crop_Progression_min     : num [1:20] 6 2 12 1 2 7 11 3 1 0 ...
 $ Crop_Progression_week_min: num [1:20] 36 36 36 38 39 35 37 33 37 35 ...
 $ Crop_Progression_date_min: Date[1:20], format: "2005-09-09" "2006-09-08" "2007-09-07" "2008-09-19" ...
 $ Crop_Progression_max     : num [1:20] 99 99 100 95 95 99 99 98 93 97 ...
 $ Crop_Progression_week_max: num [1:20] 45 47 46 47 51 44 46 44 45 47 ...
 $ Crop_Progression_date_max: Date[1:20], format: "2005-11-11" "2006-11-24" "2007-11-16" "2008-11-21" ...
NULL
> tail(Yearly_min_max)
# A tibble: 6 × 37
  Year   DEC_BASIS_min DEC_BASIS_week_min DEC_BASIS_date_min DEC_BASIS_max DEC_BASIS_week_max DEC_BASIS_date_max PEO_BASIS_min
  <chr>          <dbl>              <dbl> <date>                     <dbl>              <dbl> <date>                     <dbl>
1 2021          -0.05                37   2021-09-17                 1.1                 31   2021-08-06                 0    
2 2022          -0.15                40   2022-10-07                 1.2                 28   2022-07-15                -0.35 
3 2023          -0.1                 40   2023-10-06                 0.8                 30   2023-07-28                -0.28 
4 2024          -0.32                42   2024-10-18                 0.3                 30   2024-07-26                -0.23 
5 Mean          -0.174               35.6 NA                         0.436               31.1 NA                        -0.237
6 Median        -0.15                39.5 NA                         0.255               30   NA                        -0.255
# ℹ 29 more variables: PEO_BASIS_week_min <dbl>, PEO_BASIS_date_min <date>, PEO_BASIS_max <dbl>, PEO_BASIS_week_max <dbl>,
#   PEO_BASIS_date_max <date>, ESL_BASIS_min <dbl>, ESL_BASIS_week_min <dbl>, ESL_BASIS_date_min <date>, ESL_BASIS_max <dbl>,
#   ESL_BASIS_week_max <dbl>, ESL_BASIS_date_max <date>, FUT_1_min <dbl>, FUT_1_week_min <dbl>, FUT_1_date_min <date>,
#   FUT_1_max <dbl>, FUT_1_week_max <dbl>, FUT_1_date_max <date>, FUT_2_min <dbl>, FUT_2_week_min <dbl>, FUT_2_date_min <date>,
#   FUT_2_max <dbl>, FUT_2_week_max <dbl>, FUT_2_date_max <date>, Crop_Progression_min <dbl>, Crop_Progression_week_min <dbl>,
#   Crop_Progression_date_min <date>, Crop_Progression_max <dbl>, Crop_Progression_week_max <dbl>, Crop_Progression_date_max <date>