[R] Show Progress in loop
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Oct 10 11:22:07 CEST 2005
"Rainer M. Krug" <RKrug at sun.ac.za> writes:
> I put print(i) in the loop instead of i, but it still only prints (in
> the Windows R GUI) i after it finished the calculations.
> I guess it might be due to the output buffering you mentioned - but how
> do I unset it?
Using the user friendly interface... (it's on one of the top menus),
or, as Uwe suggested, stick in flush.console() after the print(i).
-p
> Rainer
>
> Peter Dalgaard wrote:
> > "Rainer M. Krug" <RKrug at 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.
> >
>
>
>
> --
> NEW TELEPHONE NUMBER
> Tel: +27 - (0)72 808 2975 (w)
>
> Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
> Biology (UCT)
>
> Department of Conservation Ecology
> University of Stellenbosch
> Matieland 7602
> South Africa
>
> Tel: +27 - (0)72 808 2975 (w)
> Fax: +27 - (0)21 808 3304
> Cell: +27 - (0)83 9479 042
>
> email: RKrug at sun.ac.za
> Rainer at krugs.de
>
> ______________________________________________
> R-help at 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
>
--
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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list