[R] calling R from a shell script and have it display graphics

Don MacQueen macq at llnl.gov
Thu Feb 12 16:45:42 CET 2004


I don't know about the "simpler" part, but you could use the tcltk 
package to put up a window that prompts the user to continue.

-Don


At 11:57 AM +0100 2/12/04, Christophe Pallier wrote:
>Hello,
>
>I am running R under Linux/x11.
>
>I would like to call R from a shell script and have it display a 
>series of graphics.
>The graphics should remain visible until the user clicks or presses a key.
>
>I first tried R BATCH, but it does not load the x11 module, making 
>it impossible to open x11 or png devices.
>
>Then, I tried to call R with a 'here' script:
>
>R --vanilla --quiet --args text.txt <<'EOF'
>file=commandArgs()[5]
>cat('processing ',file,'\n')
>...
>x11()
>plot(f2,log='xy',type='b',las=1,cex=.5,xlab='rang',ylab='freq')
>Sys.sleep(10)
>q()
>EOF
>
>The problem with this approach is that the script cannot interact 
>with the user.
>par(ask=T) will fail because it reads input from the script rather 
>than from the keyboard.
>
>While I am writing this, a solution comes to my mind: I could save 
>all the graphics in png format (using R <script.R), and when it is 
>finished, call ImageMagick's display to show all the png (or use any 
>other diaporama system). However, I find it a dirty hack.
>
>Is there a simpler and cleaner way to achieve this?
>
>Christophe Pallier
>www.pallier.org
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list