Re: [R] Show Progress in loop

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 10 Oct 2005 - 19:00:18 EST

"Rainer M. Krug" <RKrug@sun.ac.za> writes:

> 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
> }

Just print(i) and if on Windows, remember to unset output buffering.

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Oct 10 19:10:38 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:41 EST