Join two numeric columns to create a Year-month variable

前端 未结 3 1616
慢半拍i
慢半拍i 2021-01-29 04:17

I have two numeric columns. One contains a year, one a month number. I want to join these two and make a Year-month column that is of the proper Date type. To give a background,

3条回答
  •  暖寄归人
    2021-01-29 04:29

    You could consider the yearmon class in the zoo package:

    library(zoo) zoo::as.yearmon(paste(year, month, sep='-'))

提交回复
热议问题