If you're writing a function that you expect to take a long time to complete, you might want to give feedback to the user (or even just to yourself, during the development phase) that the function is actually still running and hasn't simply hung. The obvious solution is to include a statement like
cat(iter/totaliters,"% complete...")
in the loop. However, if you're using anything other than the console version of R, the R GUI will hold any such output until the function completes, defeating the purpose. Mark Heckmann explains how you can turn off this "console buffering" feature so that you can see the progress output. But then he goes one better: how about building a graphical progress bar? See his post for a neat example of building such GUI elements with Tcl/Tk.



You can also use 'create_progress_bar()' in the plyr package :
R <- 1000
progress_bar_text <- create_progress_bar("text")
progress_bar$init(R)
for (i in 1:R) {
j <- i
progress_bar$step()
}
cat("\n")
progress_bar_tk <- create_progress_bar("tk")
progress_bar$init(R)
for (i in 1:R) {
j <- i
progress_bar$step()
}
cat("\n")
Posted by: david | March 19, 2009 at 13:39
R <- 1000
progress_bar_text <- create_progress_bar("text")
progress_bar_text$init(R)
for (i in 1:R) {
j <- i
progress_bar_text$step()
}
cat("\n")
progress_bar_tk <- create_progress_bar("tk")
progress_bar_tk$init(R)
for (i in 1:R) {
j <- i
progress_bar_tk$step()
}
cat("\n")
Sorry for the mistake
Posted by: david | March 19, 2009 at 13:43