[Rd] example(..., ask=getOption("example.ask"))

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Wed 13 Sep 2006 - 09:51:51 GMT


Hi,

I wish to return to the topic "[Rd] example(ask = .) - default ?" discussed in R-devel on May 1, 2006, because I think it is related to my problem.

In one of my Rd examples I generate multiple (20-30!) PNG files using png()/dev.off(). I noticed that I get a "Hit <Return> to see next plot:" for each png() call, when calling example() [interactively].

The code for example() has:

    if (ask == "default")

        ask <- echo && dev.interactive(orNone = TRUE)     if (ask) {

        if (.Device != "null device") {
            opar <- par(ask = TRUE)
            on.exit(par(opar))
        }
        op <- options(par.ask.default = TRUE)
        on.exit(options(op), add = TRUE)
    }

When calling example() interactively, either with ask=TRUE (explicitly or indirectly with getOption("example.ask") == "default"), option 'par.ask.default' is set to TRUE. This seems to be the reason for the above. Example:

> options(par.ask.default=TRUE)
> png("foo.png"); plot(1); dev.off()

Hit <Return> to see next plot:
null device

          1
> options(par.ask.default=FALSE)
> png("foo.png"); plot(1); dev.off()

null device

          1

Best

Henrik



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Sep 13 19:56:01 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 Wed 13 Sep 2006 - 11:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.