How can I check whether an integer vector is “sequential”, i.e. that the difference between subsequent elements is exactly one. I feel like I am missing something like “is.sequential”
Here’s my own function:
is.sequential <- function(x){
all(diff(x) == rep(1,length(x)-1))
}
There’s no need for
repsince 1 will be recicled:Edited to allow 5:2 as true
To allow for diferent sequences