creates a monthly date vector from a date vector
date_ym(x)
a date
date vector
seq.Date(lubridate::ymd(20200101), lubridate::ymd(20220101), length.out = 10) -> d1
d1 %>%
tibble::enframe() %>%
dplyr::mutate(YM = date_ym(value))
#> # A tibble: 10 × 3
#> name value YM
#> <int> <date> <date>
#> 1 1 2020-01-01 2020-01-01
#> 2 2 2020-03-22 2020-03-01
#> 3 3 2020-06-11 2020-06-01
#> 4 4 2020-08-31 2020-08-01
#> 5 5 2020-11-20 2020-11-01
#> 6 6 2021-02-10 2021-02-01
#> 7 7 2021-05-02 2021-05-01
#> 8 8 2021-07-22 2021-07-01
#> 9 9 2021-10-11 2021-10-01
#> 10 10 2022-01-01 2022-01-01