[Rd] R command to refresh graphical output?

Parker Jones zoubidoo at hotmail.com
Wed Jan 23 14:16:55 CET 2008


Hello,

Is there are an R command to refresh the graphical output?

On a linux system I'm sending commands to R through a named pipe.   The R server is an infinite loop that listens on the pipe and executes received R code.  But I am having a problem refreshing the graphics output.  If I send a plot command down the pipe the graphical output appears.  However, if a window briefly obscures the graphical output, the x11 device won't refresh the display.  It would appear there is no refresh because R is busy interpreting infinite loop.

Is there a way of "manually" refreshing the display?  Or is there another way to get around the refresh problem?

Thanks in advance,
PJ




The R server:
# based on http://tolstoy.newcastle.edu.au/R/help/01c/2886.html
stream <- fifo("R_pipe", "r", blocking=FALSE,)
repeat
 {
  a <- readLines(stream)
  if(length(a) != 0)
   {
    if (inherits(e, "try-error"))
     {
      # error handling code here
      cat("Error", "\n")
     }
   }
 }


The R client:
$ mkfifo R_pipe
$ cat>> R_pipe
 
Now, I can send R commands down the pipe:
 
Client side:
x <- seq(1,10)
x
 
Server side:
> x <- seq(1:10)
> x
 [1]  1  2  3  4  5  6  7  8  9 10
 
So far so good.  Now send a plot, e.g. plot(1:100) and obscure the resulting plot so that it needs a refresh.  Voila, no refresh.



More information about the R-devel mailing list