Hi,
I bump into a problem where I need to compute the duration from session_start_text and session_end_text
However, the data does not give the date information, so when the session_end_text is 00:01:00, means the day after, which makes duration is negative
session session_start_text session_end_text clickouts booking duration
<chr> <time> <time> <dbl> <dbl> <dbl>
1 20170503000001 06:11:53 06:15:11 3 0 198
2 20170503000002 21:06:41 21:08:23 3 0 102
3 20170503000003 12:03:01 12:06:02 3 0 181
4 20170503000004 05:58:00 06:02:56 0 0 296
5 20170503000005 09:13:43 09:17:01 1 0 198
6 20170503000006 01:27:37 01:30:23 4 0 166
Here is the code I run to find the duration
session_data$duration <- as.numeric(session_data$session_end_text-session_data$session_start_text,units="secs")
I tried to use If function to transformed it but did not work
session_data$session_end_text_transformed <- if(as.time(session_data$session_end_text<00:10:00)){
+ as.time(session_data$session_end_text_transformed + 24:00:00)
+ } else {as.time(session_data$session_end_text)}
Maybe the code I tried to transformed is wrong, if you can come up with easier way. Please let me know
TIA.