Skip to content
Prev 132837 / 398502 Next

Conditionally incrementing a loop counter: Take 2

John Fox wrote:
As I read it, it is the sequence of i's not the x's that are sought. The 
example suddenly skipped from something with x > .7 to something with x 
< .1, but it might be that Mike's while loop just needed to print i at 
the top of the loop rather than at the bottom. The result should 
(AFAICS) be equivalent to

 > rep(1:10, 1+rgeom(10, .7))
 [1]  1  1  2  3  4  5  6  7  8  8  9 10 10