1) yearmon First create a yearmon variable which internally represents a date by year + fraction where fraction is 0, 1/12, ..., 11/12 for the 12 months. Then we can use that or convert to Date giving several possibilities.
library(zoo)
months_since_1960 <- c(0, 1, 12, 13, 24, 25)
ym <- as.yearmon(1960) + months_since_1960 / 12
ym # year and month
## [1] "Jan 1960" "Feb 1960" "Jan 1961" "Feb 1961" "Jan 1962" "Feb 1962"
as.Date(ym) # first of month
## [1] "1960-01-01" "1960-02-01" "1961-01-01" "1961-02-01" "1962-01-01" "1962-02-01"
as.Date(ym, frac = 1) # last of month
## [1] "1960-01-31" "1960-02-29" "1961-01-31" "1961-02-28" "1962-01-31" "1962-02-28"
2) Base R With base R (no packages) we can do this to get the first of the month:
dat <- months_since_1960 |>
lapply(\(x) tail(seq(as.Date("1960-01-01"), length = x+1, by = "month"), 1)) |>
do.call(what = "c")
dat
## [1] "1960-01-01" "1960-02-01" "1961-01-01" "1961-02-01" "1962-01-01" "1962-02-01"
or for last of of month
as.Date(cut(dat + 31, "month")) - 1
## [1] "1960-01-31" "1960-02-29" "1961-01-31" "1961-02-28" "1962-01-31" "1962-02-28"
2a) or this where we can use the same transformation to get end of month if desired:
dat2 <- as.Date(ISOdate(1960 + (months_since_1960 %/% 12), months_since_1960 %% 12 + 1, 1))
dat2
## [1] "1960-01-01" "1960-02-01" "1961-01-01" "1961-02-01" "1962-01-01" "1962-02-01"