[R] hit return key before next gaph appears
Jan T. Kim
jtk at cmp.uea.ac.uk
Thu Oct 19 21:13:07 CEST 2006
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))
{
plot(dframe[[n]]);
waitFunc(n);
}
}
# 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: jtk at cmp.uea.ac.uk |
| WWW: http://www.cmp.uea.ac.uk/people/jtk |
*-----=< hierarchical systems are for files, not for humans >=-----*
More information about the R-help
mailing list