[R] monitor a simulation with a special console box?

Duncan Murdoch murdoch at stats.uwo.ca
Thu Feb 15 14:49:13 CET 2007


On 2/14/2007 6:30 PM, David Farrar wrote:
> I like to monitor simulation by reporting some current values to the 
>   console, every 25th iteration say.  I think it might be nice to have 
>   that appear in a separate window.  Anyone know how?

For relatively portable things to do with opening new windows and such, 
I'd use the tcltk package.  For example, a variation on demo(tkfaq):

     tt <- tktoplevel()
     tkwm.title(tt, "R FAQ")
     txt <- tktext(tt, bg="white")
     scr <- tkscrollbar(tt, repeatinterval=5,
                        command=function(...)tkyview(txt,...))
     ## Safest to make sure scr exists before setting yscrollcommand
     tkconfigure(txt, yscrollcommand=function(...)tkset(scr,...))
     tkpack(txt, side="left", fill="both", expand=TRUE)
     tkpack(scr, side="right", fill="y")

     for (i in 1:10)
        tkinsert(txt, "end", paste("Done step", i, "\n"))

Duncan Murdoch



More information about the R-help mailing list