I am looking for an equivalent to Excel's 24 within R. For example

You want to calculate the duration of 2 times:

| Column 1 | Column 2 |
| --- | --- |
| 22:00 | 04:00 |
| 04:00 | 08:00 |

When I use duplicate() function in R, it calculates Row B correctly, to total 4 hours.

But in Row B, because the duration goes over 24 hours, it calculates the duration to -18 hours.

Is there a way of using an equivalent of the 24 function in Excel (24+Col 2, Row A - Col, Row A) in R, to make sure that Row A totals 6 hours?

Many thanks in advance.