numbers = 1:100
for(x in seq(26,1,-2)) {
print(numbers[x:x+2])
}
And the above prints:
[1] 28
[1] 26
{etc}
[1] 4
My question is why doesn't the loop print something like a section (26 27 28
) of the list? Why does it only print out one number per iteration? And what would I have to change for the output to be slices of the list? Desired out put
[1] 27 28
[1] 25 26
{etc}
[1] 3 4
This is confusing to me since
numbers[1:5]
# prints [1] 1 2 3 4 5