suppose I have the following vector:
v1 = c(1,2,3,4)
I need to iterate over this vector in a pairwise fashion, like (1,2), (2,3), (3,4)
. For python, there is a solution to this problem here: Iterate over all pairs of consecutive items in a list. Can a similar solution be achieved in R?