I created a date called year_month which is based on the year and month, so all days in February 2014 will be 2014-02-01. Group by year_month and then calculate the mean for each group.
library(tidyverse)
library(lubridate)
dates <- c("2004-02-06","2004-02-08","2006-02-06", "2006-02-28")
values <- c(28, 32, 20, 24)
data.frame(dates, values) %>%
mutate(year_month = make_date(year = year(dates), month = month(dates))) %>%
group_by(year_month) %>%
summarise(mean = mean(values))
#> # A tibble: 2 × 2
#> year_month mean
#> <date> <dbl>
#> 1 2004-02-01 30
#> 2 2006-02-01 22
Created on 2021-12-04 by the reprex package (v2.0.1)