Re: [R] Show Progress in loop

From: Rainer M. Krug <RKrug_at_sun.ac.za>
Date: Mon 10 Oct 2005 - 19:13:48 EST

Thanks - flush.console() did the trick.

As you might guess, I am quite new to R. I like the idea of vectorizing the calculation, but I guess it is not possible in this case - I will ask in a new thread.

Thanks,

Rainer

Uwe Ligges wrote:
> 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
>> }
>>

>
>
> - Update your console (I guess you are on Windows?) by using
> flush.console().
> - You might want to measure time consumption, hence see ?Rprof.
> - Save some more time by moving as much as possible out of your loop by
> doing it in a vectorized way (I don't know all the functions you are
> using, hence cannot make any further recommendations).
>
> Uwe Ligges
-- 
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@sun.ac.za
       	Rainer@krugs.de

______________________________________________
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:33:20 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:36:20 EST