I ran into a problem in R where I need to manipulate a vector in R.
Lets say I have a vector of length 12:
vector <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
I now need to add the elements 1+2, 3+4, 5+6 etc. into a new vector, in the example that would be:
newvector <- c(3, 7, 11, 15, 19, 23)
I need to do the same for longer sequences, such that it adds the first three, then 4-6, then 7-9 etc.
newvector <- c(6, 15, 24, 33)
and so on.