This is what the sample looks like:
# A tibble: 10 x 3
trip_id start_time end_time
<dbl> <time> <time>
1 1 20:21:42 21:04:00
2 2 08:28:42 08:58:42
3 3 18:41:59 18:50:59
4 4 10:06:15 11:39:22
5 5 08:20:27 08:51:33
6 6 11:11:36 12:12:54
7 7 19:54:38 20:28:38
8 25854 11:33:22 12:05:06
9 25855 07:38:07 07:40:07
10 25856 11:33:03 11:42:02
data <- structure(list(trip_id = c(1, 2, 3, 4, 5, 6, 7, 25854, 25855,25856), start_time = structure(c(73302, 30522, 67319, 36375,30027, 40296, 71678, 41602, 27487, 41583), class = c("hms", "difftime"), units = "secs"), end_time = structure(c(75840, 32322, 67859,41962, 31893, 43974, 73718, 43506, 27607, 42122), class = c("hms","difftime"), units = "secs")), row.names = c(NA, -10L), class = c("tbl_df","tbl", "data.frame"))
As you can see, my data start_time
and end_time
columns are chr
type. Therefore, I want to convert it into a proper time class and also numerics. My output should be like this;
# A tibble: 10 x 3
trip_id start_time end_time start_time2 end_time2
<int> <dttm> <dttm> <dbl> <dbl>
1 1 20:21:42 21:04:00 20.21 21.04
2 2 08:28:42 08:58:42 08.28 08:58
3 3 18:41:59 18:50:59 18.41 18.50
4 4 10:06:15 11:39:22 10.06 11.39
5 5 08:20:27 08:51:33 08.20 08.51
6 6 11:11:36 12:12:54 11.11 12.12
7 7 19:54:38 20:28:38 19.54 20.28
8 25854 11:33:22 12:05:06 11.33 12.05
9 25855 07:38:07 07:40:07 07.38 07.40
10 25856 11:33:03 11:42:02 11.33 11.42
Thank you in advance.