Reputation: 641
I want another vector where each numeric value is = to it's current value minus (its position in the vector - 1), e.g.
Say I have
positions <- c(9, 30, 46, 52, 76)
I want another vector which is equal to c(9, 29, 44, 49, 72)
thanks
Upvotes: 1
Views: 155
Reputation: 93803
x <- c(9, 30, 46, 52, 76)
x - (seq_along(x)-1)
[1] 9 29 44 49 72
Upvotes: 6