Reputation: 1141
I've got a vector of numbers:
vec <- c(50, 75, 100, 125, 150, 200, 250, 300, 350, 400, 450, 475, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000)
I'd like to add the 10 numbers above and 10 numbers below each value. E.g. for 50 you would add 40 through to 49 and 51 through to 60.
Any help much appreciated!
Upvotes: 0
Views: 88
Reputation: 388797
Using sapply
:
c(sapply(vec, `+`, -10:10))
If the number overlap you might want to add unique
to the above output to get only unique values.
Upvotes: 2