Suppose I have the following data:
c(1:4,7:15,20:23,25,30:35,40,41)
I want to get the start and end ranges from that vector. Yet, I want to skip single values, that have no natural predecessor and successor (in the example: 25). In other words, there should be at least two consecutive values to make a "range".
The start ranges in this example are: 1, 7, 20, 30, 40
Their corresponding end ranges are: 4, 15, 23, 35, 41
Is there any elegant built-in solution? I am pretty much stuck in a for loop hell.