make_date() and make_datetime()
flights |>
select(year, month, day, hour, minute) |>
mutate(
departure = make_datetime(year, month, day, hour, minute),
dep_date = make_date(year, month, day)
)
## # A tibble: 336,776 × 7
## year month day hour minute departure dep_date
## <int> <int> <int> <dbl> <dbl> <dttm> <date>
## 1 2013 1 1 5 15 2013-01-01 05:15:00 2013-01-01
## 2 2013 1 1 5 29 2013-01-01 05:29:00 2013-01-01
## 3 2013 1 1 5 40 2013-01-01 05:40:00 2013-01-01
## 4 2013 1 1 5 45 2013-01-01 05:45:00 2013-01-01
## 5 2013 1 1 6 0 2013-01-01 06:00:00 2013-01-01
## 6 2013 1 1 5 58 2013-01-01 05:58:00 2013-01-01
## 7 2013 1 1 6 0 2013-01-01 06:00:00 2013-01-01
## 8 2013 1 1 6 0 2013-01-01 06:00:00 2013-01-01
## 9 2013 1 1 6 0 2013-01-01 06:00:00 2013-01-01
## 10 2013 1 1 6 0 2013-01-01 06:00:00 2013-01-01
## # ℹ 336,766 more rows