[R] how to pause between plots running scripts?
Terry Mu
muster at gmail.com
Sun Nov 28 03:03:16 CET 2004
Thank you.
I am using R 2.0.0 under Windows 2000.
I've tried
1. par(ask=T)
2. readline(prompt = "Pause. Press <Enter> to continue...")
1. script:
x <- 0:20
y <- 5:25
plot(y)
plot(x)
plot(y~x)
output:
> par()$ask
[1] TRUE
> x <- 0:20
> y <- 5:25
> plot(y)
Hit <Return> to see next plot: plot(x) ####R does not pause after plot(y)
#### it seems R eats the second plot(x)
> plot(y~x)
Hit <Return> to see next plot: ####R does pause here
2.
script:
x <- 0:20
y <- 5:25
plot(y)
readline(prompt = "Pause. Press <Enter> to continue...")
plot(x)
pause()
plot(y~x)
output: ####R does not pause at all
> par()$ask
[1] TRUE
> plot(y)
Hit <Return> to see next plot: readline(promp #seems plot() eats some characters
> = "Pause. Press <Enter> to continue...")
Error: syntax error
> plot(x)
Hit <Return> to see next plot: pause()
> plot(y~x)
Hit <Return> to see next plot:
I don't know if I have made some stupid mistakes or messed up some of
configurations.
*************************************************************
On Sat, 27 Nov 2004 13:07:58 -0600, Marc Schwartz
<mschwartz at medanalytics.com> wrote:
> On Sat, 2004-11-27 at 11:42 -0500, Terry Mu wrote:
>
>
> > I used pause() from library(DAAG) to pasue between plots. This works
> > when I source a script, but seems don't work when I run (ctrl + R) the
> > script in R.
> >
> > Did I do something wrong? Thanks.
>
> The standard way to pause between plots is to set 'par(ask = TRUE)'
> before your first plot, which will then prompt you to continue after
> each new plot. See ?par for more information.
>
> I am presuming that you are using Windows, which you do not indicate,
> with CTRL-R being the command to paste and run code from the R Windows
> GUI editor.
>
> >From a scan of the code for DAAG's pause(), it appears to use the
> readline() function to prompt for user input as the basis for the
> pausing.
>
> A scan of the source code in .../gnuwin32/editor.c indicates that the
> copy and paste operation to the Rgui console from the editor takes place
> via the clipboard in function editorrunselection, if my read is correct.
>
> I would defer to Duncan Murdoch and Prof. Ripley here, but I suspect
> that there may be some interaction between readline() and the
> copy/paste/run mechanism that precludes pause() from running in this
> situation.
>
> A quick test you might want to run would be to replace pause() with:
>
> readline(prompt = "Pause. Press <Enter> to continue...")
>
> in your code to see if this behavior continues, independent of the DAAG
> package. You should also notify the DAAG package authors/maintainer of
> the issue.
>
> HTH,
>
> Marc Schwartz
>
>
More information about the R-help
mailing list