I have a vector in R:
> v <- c(5, 10, 15, 20, 25, 30, 35, 40, 45, 50)
I would like to apply a function to every nth element of the vector and have it return the new vector. For example, let's say I would like to multiply every third element of the vector by 2. I would then get
> v
[1] 5 10 30 20 25 60 35 40 90 50
I have managed to extract elements using vector logic:
> v[c(rep(FALSE,2),TRUE)]
[1] 15 30 45
meaning I have figured out how to access the elements and I am able to do things to them, but I don't know how to get them back into my original vector v
.