I have a data frame and it looks like this:
submition_id time_answered
2 2017-11-06 14:19:30
2 2017-11-06 14:22:45
2 2017-11-06 14:24:55
2 2017-11-06 14:34:10
4 2017-11-06 14:31:23
4 2017-11-06 14:33:21
5 2017-11-06 14:54:48
5 2017-11-06 14:59:38
5 2017-11-06 15:05:39
... ...
So basically my submition_id column is a factor column and time_answered column is POSIXct column. I want to find the time difference for each factor which is basically max(x) - min(x). How can I do this effective with inbuilt functions? Such that I get
submition_id difference
2 14.67
4 1.96
5 9.77
... ...
I would like it in minutes as well.