I would like to get the last day of the month from a year/month variable that is formated as integer YYYYMM.
yearmonth <- c(seq(202001,202012),
seq(202101,202112))
The output I am looking for is below. For instance, the last day of Feb/2020 was 29 (2020 was a leap year) whereas the last day of Feb/2021 was 28.
last <- c(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
Ideally I would like to use the lubridate
package.