Skip to content
Prev 13973 / 398502 Next

problem with while loop with next (was RE: [R] file connection, w hile, readLines and browser)

Dear R-help,

I think I have kinda isolated the problem I had to the following:

i <- 0
while( {i <- i + 1} < 5) {
  if(i < 3) next
  print(i)
}

This seems to go into an infinite loop.  After I break the execution, i has
the value 1.

At the R prompt, if I start from i <- 0 and keep typing {i <- i + 1} < 5, it
eventually evaluate to TRUE.  So why does the while loop not work?

(BTW, the same while loop runs as I expected in Splus 6.0.3 on WinNT.)

Any hints?  I'd really appreciate the help!

Cheers,
Andy
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._