I have a series of numbers between 1 to 10 in ascending order which some numbers are missing. I want to find the first number for each missing gap. I'm doing this in R. For example:
You can accomplish this using
diff and subsetting as follows
numbers[diff(numbers) != 1] + 1  3 8
diff(numbers) != 1 will return a logical vector where adjacent elements are not equal to the next number in the "counting" order.
numbers will subset these, then add 1 to return the missing values.