[R] Default par() options
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Fri Mar 2 01:13:08 CET 2007
Hi Bert,
On Thursday 01 March 2007 23:59, Bert Gunter wrote:
> I am not sure exactly what you are asking for below,
I guess I'm really asking for some advanced comfort / elegance. See below.
> but I wonder if your
> query could be satisfied by the judicious use of the ... argument in a
> wrapper function to par(), like
>
> myPar=function(bg="lightgray", pch=19,...)par(bg=bg,pch=pch,...)
True. Such a function solves most of "the issue". Also, it should work
universally for all types of devices. However, a manual call to myPar() would
need to be added after each creation of a new device.
> or perhaps
>
> myX11 <- function(width=10, bg="lightgray", pch=19,...)
> {
> X11(width=width)
> par(bg=bg,pch = pch,...)
> }
This one would automate the call to par(), but a similar function would be
needed for each type of device (X11(), postscript(), pdf(), etc.) in order to
achieve a fully automatic consistent behavior.
Also in this case options("device") would need to be adjusted, which is no big
deal, but simply doesn't feel nice.
> This would use the existing user-chosen defaults for the respective devices
> if no other values were provided, and would allow the user to explicitly
> specify any different values for them or additional arguments to par if
> needed. I agree that it ain't elegant, though, so I'd welcome better
> alternatives, too.
Part of the background is that I'm writing a GUI frontend to R. Both of your
suggested solutions certainly work well, and are easy enough to use,
regularly. For writing the frontend, however, we'd like to support all sorts
of devices (the standard ones, and ones in uncommon packages / future
devices) in a consistent way, and with as little code as possible (add to
that: without using obscure tricks, so the user will easily be able to
understand what's going on, and achieve the same results on the R command
line). So that's what makes me look for (excessive?) elegance in this case.
> Of course, one can explicitly use formals() and the construction:
>
> dots <- as.list(substitute(list(...)))[-1] ## V&R: S PROGRAMMING p. 46
>
> to obtain all the arguments and their names and appropriately stuff them
> into either par() or X11() using do.call() or something similar; but that
> seems like more than you need here.
Not what I'm looking for, here, but that trick may come in handy in a
different situation. Thanks!
Regards
Thomas Friedrichsmeier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20070302/8708dc7b/attachment.bin
More information about the R-help
mailing list