Skip to content

how to pause between plots running scripts?

4 messages · Marc Schwartz, Terry Mu, Duncan Murdoch

#
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.
#
On Sat, 2004-11-27 at 11:42 -0500, Terry Mu wrote:
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.
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
#
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:
[1] TRUE
Hit <Return> to see next plot: plot(x) ####R does not pause after plot(y)
#### it seems R eats the second plot(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
[1] TRUE
Hit <Return> to see next plot: readline(promp #seems plot() eats some characters
Error: syntax error
Hit <Return> to see next plot: pause()
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:
#
This sounds like a bug to me, but I'm not sure it's going to be an
easy one to fix.  

Duncan Murdoch