[R] Show Progress in loop

ernesto ernesto at ipimar.pt
Mon Oct 10 11:37:14 CEST 2005


Rainer M. Krug wrote:

>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?
>
>Rainer
>
>The loop:
>
>for (i in 2:Result$NoSims)
>{
>	ppp <- runifpoint(Result$NoPlants)
>	K <- Kest(ppp)
>	Result$LSim[i,] <- sqrt(K$iso / pi) - K$r
>	CM <- (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1])
>	Result$SigCM[i] <- sum(CM, na.rm=TRUE)
>	i  #<========================Doesn't display in the loop
>}
>
>  
>
Hi,

You can simply include a command like

cat("loop: " , i, "\n")

inside your loop.

EJ




More information about the R-help mailing list