Merge three different columns into a date in R

Try:

  df$date <- as.Date(with(df, paste(year, mon, day,sep="-")), "%Y-%m-%d")
   df$date
  #[1] "1947-01-01" "1947-04-01" "1947-07-01" "1947-10-01" "1948-01-01"
  #[6] "1948-04-01"

Leave a Comment