[R] Show Progress in loop

vincent@7d4.com vincent at 7d4.com
Mon Oct 10 11:25:51 CEST 2005


Rainer M. Krug a écrit :

> Hi
> I have a loop which is doing time consuming calculations and I would 
> like to be able to have some feedback on where it is in it's 
> calculations. I tried to simply show the counter variable in the loop, 
> but id doesn't work as all display seems to be delayed until the loop is 
> completed. Is there any way of displaying the progress of a loop?
> 
> for (i in 2:Result$NoSims)
> {
> 	...
> 	i  #<========================Doesn't display in the loop
> }
> 

Hi,
for your last line, use :

print(i);
flush.console();  #<====== now displays in the loop

hih




More information about the R-help mailing list