Skip to content
Prev 22936 / 398502 Next

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

The problem is that the '1:n' in 'for(i in 1:n)' is only evaluated once
at the beginning of the loop, so altering 'n' later does not change the
loop behavior. Try something like:

i <- 0
repeat {
	i <- i + 1
	cat(i, '\n')
	if (i > 9) break
}

T.
On Mon, 2002-08-26 at 14:50, Huntsinger, Reid wrote:
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._