I have a timeseries of gps data, that needs to be segmented into smaller parts based on gaps in the time stamps.
As an example, consider the following data frame, I want to add a segment number that segments each 'chunks' of time stamps, effectively spitting the data each time there is a gap in the time series of at least 30 seconds.
The resulting data.frame would look something like this:
timestamp segment
1 1 1
2 3 1
3 5 1
4 10 1
5 42 2
6 45 2
7 92 3
8 156 4
9 160 4
10 162 4
11 163 4
12 164 4
13 200 5
14 203 5
Any way of doing this effectively? The data.frame is a grouped tbl_df (dplyr package) with several distinct time series and can be quite large.