library(dplyr)
library(lubridate)
I have some data like this
f <- tribble(~a, ~date,
"BVH", 201801,
"HBYU", 202012,
"CYC", 202112,
"AC", 202109)
And I need to transform it to the last day of month, I do this
f %>% mutate(date = ym(date))
# A tibble: 4 x 2
a date
<chr> <date>
1 BVH 2018-01-01
2 HBYU 2020-12-01
3 CYC 2021-12-01
4 AC 2021-09-01
What I would like is, this
# A tibble: 4 x 2
a date
<chr> <date>
1 BVH 2018-01-31
2 HBYU 2020-12-31
3 CYC 2021-12-31
4 AC 2021-09-30