This question is very similar to a question asked in another thread which can be found here. I\'m trying to achieve something similar: within groups (events) subtract the first
We can use difftime and specify the unit to get all the difference in the same unit.
difftime
unit
df %>% group_by(event) %>% summarise(First = first(time), Last = last(time) , difference= difftime(last(time), first(time), unit='hour'))