[R] Printing the loop number for each iteration
Jim Holtman
jholtman at gmail.com
Thu Jul 21 13:26:09 CEST 2011
if using the GUI, turn off buffering, or use 'flush.console()' after 'cat'.
Sent from my iPad
On Jul 21, 2011, at 7:34, "Bogaso Christofer" <bogaso.christofer at gmail.com> wrote:
> Hi all, I have a lengthy 'for' loop and for each loop I want to track the
> iteration number that is currently going on. For this, I have tried
> following:
>
>
>
>> for (i in 1:10) {
>
> + DumDat <- rnorm(1000)
>
> + cat("iteration:", i, " \n")
>
> + }
>
> iteration: 1
>
> iteration: 2
>
> iteration: 3
>
> iteration: 4
>
> iteration: 5
>
> iteration: 6
>
> iteration: 7
>
> iteration: 8
>
> iteration: 9
>
> iteration: 10
>
>
>
> However when I run this loop, all iteration numbers are showing only after
> completion of all calculation, so could not achieve my goal. Can somebody
> help me out, how can I do that?
>
>
>
> Thanks,
>
>
>
>
>
>
> [[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.
More information about the R-help
mailing list