I have data with an example as follows (I use R
):
A B C
1 2 Background
3 19 Background
26 41 person
43 69 person
83 97 Background
107 129 Background
132 179 Background
189 235 Background
243 258 Background
261 279 person
I would like to add rows where the difference between col A row N+1 and col B row N > 1 and row C gets a label (e.g. 'other'). So the data would look like this:
A B C
1 2 Background
3 19 Background
20 25 other
26 41 person
43 69 person
70 82 other
83 97 Background
98 106 other
107 129 Background
130 131 other
132 179 Background
180 188 other
189 235 Background
236 242 other
243 258 Background
259 260 other
261 279 person
Thanks!