Skip to content

get plot in a window when running R in the shell

2 messages · bogdan romocea, Barry Rowlingson

#
Dear useRs,

On a GNU/Linux box I want to run some code from the command line. This works
   #!/bin/sh
   R --vanilla -q --gui=X11 < code.r
however I want the plots to appear in a window (as it happens when the
code is run interactively) instead of being saved in 'Rplots.ps'. Is
that doable?

Thank you,
b.
#
bogdan romocea wrote:

            
You could explicitly startup an X11 graphics device before your first 
plot in your R source code, something like:

  x11()
  hist(runif(100))

Works for me, although the window will disappear very quickly unless the 
script pauses before ending!

Baz