Skip to content
Back to formatted view

Raw Message

Message-ID: <16429.9895.204135.788659@arbres1a.fmr.com>
Date: 2004-02-13T19:33:59Z
From: David Brahm
Subject: calling R from a shell script and have it display graphics

Christophe Pallier <pallier at lscp.ehess.fr> wrote:
> 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.

One trick is to use locator(1), which waits for a mouse click on a plot.
Here's a minimal Perl script that runs R, displays a plot, and exits when the
click is detected.


eval 'exec /usr/local/bin/perl -s -S $0 "$@"'
  if 0;
open(SCRIPT, "| R --vanilla --slave");
print SCRIPT <<'EOF';

x11(width=5, height=3.5)
plot(1:10, 1:10)
z <- locator(1)
q()

EOF
close(SCRIPT);

-- 
                              -- David Brahm (brahm at alum.mit.edu)