Skip to content
Prev 150998 / 398498 Next

incrementing for loop by 2

on 07/24/2008 07:59 AM Clark, Jennifer H wrote:
It would be helpful to have an idea of what you are trying to 
accomplish, as there may very well be a better way than using a 'for' loop.

That being said:

 > for (i in seq(0, 10, 2)) print(i)
[1] 0
[1] 2
[1] 4
[1] 6
[1] 8
[1] 10


See ?seq

HTH,

Marc Schwartz