[R] calling R from a shell script and have it display graphics
David Brahm
brahm at alum.mit.edu
Fri Feb 13 20:33:59 CET 2004
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)
More information about the R-help
mailing list