Creating a time-stamp variable out of six columns from an csv-file

Here is an example with made-up data

library(dplyr)
library(lubridate)

sample_df <- data.frame(
    year = c(2020, 2020),
    month = c(07, 08),
    day = c(22, 23),
    hour = c(10, 11),
    minute = c(01, 02),
    second = c(30, 32)
)

sample_df %>% 
    mutate(date = make_datetime(year, month, day, hour, minute, second))
#>   year month day hour minute second                date
#> 1 2020     7  22   10      1     30 2020-07-22 10:01:30
#> 2 2020     8  23   11      2     32 2020-08-23 11:02:32

Created on 2020-07-09 by the reprex package (v0.3.0)

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

2 Likes