0

Using tidyverse I have the following data:

ID   timestamp
001  2021-06-04 09:45:25
001  2021-06-04 09:46:25
001  2021-06-04 09:46:35
002  2021-06-04 05:45:25
002  2021-06-04 09:45:25
004  2021-06-04 09:15:12
003  2021-06-04 09:45:25
004  2021-06-06 09:45:25
004  2021-06-04 09:45:25

And Basically I want to show the time difference between an ID's first timestamp and last in whatever format makes sense.

So the end result should look like this, x's being the difference in time fromt the MIN(TIMESTAMP and MAX(TIMESTAMP) from a given ID:

ID  time_diff
001  xxxx
002  xxxx
003  NA
004  xxxx
John Thomas
  • 1,075
  • 9
  • 32
  • From a cursory look I'm not sure if the linked post that closed this question actually answers your question, so I thought I'd give you an idea of how I'd do this @John Thomas, group_by(ID)%>% summarise(time_diff = (min(timestamp) - max(timestamp)))%>% ungroup() – Silentdevildoll Sep 23 '21 at 22:31
  • @Silentdevildoll this is close!!! i can approve your answer if u response :) – John Thomas Sep 24 '21 at 17:16

0 Answers0