I would like to turn this list [1, 2, 3, 4, 5, 6, 7, 8, 9] into the following set of vectors
[1, 2, 3, 4, 5, 6, 7, 8, 9]
(2,3,4) (3,4,5) (4,5,6) (5,6,7) (6,7,8) (7,8,9)
x = c(1, 2, 3, 4, 5, 6, 7, 8, 9) n = length(x) lapply(1:(n - 2), function(i) x[i:(i + 2)])
2.1m questions
2.1m answers
60 comments
57.0k users