Probably this would be easy. I have a Matrix:
testM <- matrix(1:40, ncol = 4, byrow = FALSE) testM [,1] [,2] [,3] [,4] [1,] 1 11 21 31 [2,]
a solution around your initial idea:
sapply(seq(2, ncol(testM), 2), function(x) apply(testM[, (x-1):x], 1, sum))