I have a `data.table` ordered by DateTime like below and want to analyse the time difference between ID = 1 and the ID's 2 to 5, separated by state and the repeating sequences of the state.

```
structure(list(DateTime = structure(c(1533081601.42, 1533081601.98, 
                                      1533081601.98, 1533081601.98, 1533081602.02, 1533081928.06, 1533081928.22, 
                                      1533081928.22, 1533081928.22, 1533081928.22, 1533081952.34, 1533081952.94, 
                                      1533081952.94, 1533081952.94, 1533081952.98, 1533081953.98, 1533081954.14, 
                                      1533081954.14, 1533081954.14, 1533081954.14), class = c("POSIXct", 
                                                                                              "POSIXt"), tzone = "UTC"), ID = c(1, 3, 4, 5, 2, 1, 2, 3, 4, 
                                                                                                                                5, 1, 3, 4, 5, 2, 1, 2, 3, 4, 5), state = c(0L, 0L, 0L, 0L, 0L, 
                                                                                                                                                                            1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L)), class = c("data.table", 
                                                                                                                                                                                                                                                    "data.frame"))

```

ID 1 is always first in a sequence but the order of ID's 2 -5 after ID 1 is changing. The sequence of state(s) is just a repeating of 0 and 1.

For each run of the IDs 1 to 5 having the same state (1 or 0) I want to get the time difference between ID 1 and the other IDs.

A `data.table()` approach is preferred but any advice is welcome!!!