I am trying to create a function that will return the first integer of a subset of a vector such that the values of the subset are discrete, increasing by 1, and of a specified length.
For example, using the input data 'v' and a specified length 'l' of 3:
v <- c(3, 4, 5, 6, 15, 16, 25, 26, 27)
l <- 3
The possible sub-vectors of consecutive values of length 3 would be:
c(3, 4, 5)
c(4, 5, 6)
c(25, 26, 27)
Then I want to randomly choose one of these vectors and return the first/lowest number, i.e. 3, 4, or 25.