diff () calculates the difference between the values ββin the vector for a given delay. Is there an equivalent function working on two vectors? For example, I have:
v1 = c(1, 2, 3, 4, 5, 3) v2 = c(5, 4, 3, 2, 1, 0)
I need to calculate the difference between each value of v1 and v2 at a delay of 1. This will be:
(2 - 5), (3 - 4), (4 - 3)...
This can be achieved using head () / tails () combinations on 2 vectors, but I was wondering if there is already a function that can do the same.
Robert Kubrick
source share