Or you can use the lubridate package, which simplifies working with dates and times in R.
eg.
df$date <- with(df, ymd(sprintf('%04d%02d%02d', year, mon, day))) df$date
The ymd function takes a string representing Year, Month, and Day, which can be "19470101", "1947-01-01", "1947/01/01", etc. In addition, there are also mdy and dmy if the elements are ordered differently. You can also specify the time zone.
source share