Skip to content
Prev 22935 / 398502 Next

updating n within for(i in 1:n) loop

Why not use a "while" loop instead?

n <- 2
i <- 1
 while (i <= n)
 {
   cat(paste("i =", i, "\n")); flush.console()
   n <- 5  # version 1
   i <- i+1
  }

I think the above should work.

Ravi.


----- Original Message -----
From: "Prasad, Rajiv" <Rajiv.Prasad at pnl.gov>
Date: Monday, August 26, 2002 1:54 pm
Subject: [R] updating n within for(i in 1:n) loop
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._