Dear R community members, i would like to create a new variable (commute time) based on the difference between the departure and arrival time of commuters (Arrivaltime - Departuretime) from the Origin to their destination (24 hour format).
However, the problem is that the column is numeric and the values more than 30 minutes are not captured as minutes. I want my commutetime be in minutes not in hours. Below is the format of my dataset.
Departuretime Arrivaltime commutetime
950 1000 50
1030 1035 5
1750 1800 50
1520 1530 10
When i take the difference between the departure and arrival time, things get weird beyond 30 minutes which you of course would expect to happen. My dataframe has got 6,670 entries and these columns are the only problematic thing. The difference between 950 and 1000 should translate into the difference for 9:50 and 10:00 and therefore the difference can't be 50. As illustrated in the second last row, the difference between 1750 and 1800 should not yield 50.
I would immensely appreciate your timely help.
Thank you!!!