Join two numeric columns to create a Year-month variable

前端 未结 3 1617
慢半拍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:48

    Just add a 01 in your paste and use as.Date

    as.Date(paste(year, month, '01', sep= '-'))
    

提交回复
热议问题