Here's a solution for Windows, for use with graphics::plot.
Using, Linux and grid or ggplot2, may require some modification.
(However, I assuming the modifications would be easy to make).

You can create a file, say quasi_interactive.r

----quasi_interactive.r----
#for use with windows only
options (device = windows)

.initialize = function ()
{   n = length (dev.list () )
    if (n == 0)
        windows ()
    else
        locator (1)
}

.finalize = function ()
{   n = length (dev.list () )
    if (n > 0)
        invisible (locator (1) )
}

#assumes plots called with graphics::plot function
plot = function (x, ...)
{   .initialize ()
    graphics::plot (x, ...)
}

args = commandArgs (TRUE)
source (args [1])

.finalize ()
----end-of-file----

Then at the terminal, use either of:
> Rscript quasi_interactive.r my_script_file.r
> R -f quasi_interactive.r --args test.r

The first option is probably better.

Also, instead of locator (1) you could test for text input (say by
pressing enter), or wait (say 10 seconds per plot).
Another option is to open one graphics device for each plot.

B.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to