Re: [R] hit return key before next gaph appears

From: Jan T. Kim <>
Date: Thu 19 Oct 2006 - 19:13:07 GMT

On Thu, Oct 19, 2006 at 02:28:01PM -0400, Chuck Cleland wrote:
> Leeds, Mark (IED) wrote:
> > i am looping and creating plots which are coming to the screen. i am in
> > linux and remember ( in a previopus life ) i used to use a command so
> > that the next graph n + 1 didn't appear on the screen until
> > i hit the return key after graph n appeared. i thought i remeber using
> > the command unix but when i type unix at the r prompt, it gices me
> > system. it's probably a deprecated
> > command then but i still don't remember what i did to make the next
> > graph not appear until i hit the return key. or maybe it was any key for
> > that matter. thanks a lot.
> par(ask=TRUE)
> plot(rnorm(10))

As a somewhat more "advanced" variant, it's also possible to manually engineer the waiting for the return key. I sometimes do this in loops, as in

    hitReturn <- function(msg)
      invisible(readline(sprintf("%s -- hit return", msg)));     }

    plotAllColumns <- function(dframe, waitFunc = hitReturn)     {

      for (n in colnames(dframe))


    # demo:
    dframe <- data.frame(x = runif(10), y = rnorm(10), z = rexp(10));     plotAllColumns(dframe);

I find this useful to keep track of what the current plot actually is displaying. Furthermore, it's possible to run a simplistic kind of animation, as in

    plotAllColumns(dframe, function(msg) { print(msg); Sys.sleep(3); });

Best regards, Jan

 +- Jan T. Kim -------------------------------------------------------+
 |             email:                               |
 |             WWW:             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Oct 20 05:19:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 19 Oct 2006 - 19:30:11 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.