Re: [R] Displaying Iteration Count

From: Shotwell, Matthew S <shotwelm_at_musc.edu>
Date: Tue, 22 Jun 2010 09:32:37 -0400

or... for every 100 iterations

telliter <- 100
for( iter in 1:maxiter ) {

    #do some cool statistics
    if( iter %% telliter == 0 ) cat(paste("iteration", iter, "complete\n")) }

-Matt



From: r-help-bounces_at_r-project.org [r-help-bounces_at_r-project.org] On Behalf Of Henrique Dallazuanna [wwwhsd_at_gmail.com] Sent: Tuesday, June 22, 2010 9:15 AM
To: Downey, Patrick
Cc: R help
Subject: Re: [R] Displaying Iteration Count

Try this:

for(i in 1:10) {

    print(sprintf("Interation: %d", i))
    flush.console()
    Sys.sleep(1)
}

On Tue, Jun 22, 2010 at 10:07 AM, Downey, Patrick <PDowney_at_urban.org> wrote:

> Hello,
>
> I'm running a very long for loop that usually takes hours. For my own piece
> of mind, it would be nice if I could check periodically and see which
> iteration the loop is on. A line of code that told R to print the iteration
> number every 100 or 200 iterations would be perfect.
>
> Does anyone know something like this? I've never known how to print
> anything within a for loop before the loop ends.
>
> Thanks,
> Mitch
>
> ______________________________________________
> R-help_at_r-project.org mailing list

> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 22 Jun 2010 - 13:35:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Jun 2010 - 13:40:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive