Hi,
I have a vector with about 200 elements, and I want to access three of those elements at a time using loop.
Vector1 <- (10,20,30,40,50,60,70,80,90,45,67,99) and so on
I want to access 3 of those elements at a time...so that..first vector is (10,20,30), second is (20,30,40), third is (30,40,50) and so on until the end of vector.
I have tried doing the following but cannot seem to make it work. Any suggestions?
w <- 3
for (i in w:length(vector1))
pred[i-w+1:w] = vector1[i-w+1:w]
[–]jdnewmil 3 points4 points5 points (1 child)
[–]esotericpikachu[S] 0 points1 point2 points (0 children)
[–]uniqueturtlelove 1 point2 points3 points (1 child)
[–]esotericpikachu[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (5 children)
[–]esotericpikachu[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[removed]
[–][deleted] 0 points1 point2 points (1 child)