[R] cursor after txtProgressBar

Jinsong Zhao jszhao at yeah.net
Mon Mar 25 13:11:14 CET 2013


Hi there,

I am using R 2.15.2 under Win7 64. I hope to display progress bar when I 
am running a loop. After the loop exit, the cursor is at the right 
margin of the window. How can I make it to the left margin?

Here is the minimal example code.

combn.bar <- function(n, m) {
     n <- choose(n, m)
     pb <- txtProgressBar(1,n,style = 3)
     for (i in 1:n) {
         Sys.sleep(0.1)
         setTxtProgressBar(pb, i)
     }
     close(pb)
}

combn.bar(6,3)

I try to move the cursor to the left margin using cat("\r"). However, 
after that, I can not move the cursor to left if I try to edit a history 
command.

It seems a problem that only related with Rgui. I try the above example 
in Rterm, it works well.

Any help will be really appreciated.

Regards,
Jinsong



More information about the R-help mailing list