Warning in par(args)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
24 Jun 1998 12:09:37 +0200


Martin Maechler <maechler@stat.math.ethz.ch> writes:

>     MM>    on.exit(par(op))
>     MM>    op <- par(xyx = ...,  brd = ...)
>     MM>    work.work2()
>     MM>    op <- c(op, par(ghj = ...,  klm = ...))
>     MM>    work.work3()
...
> Therefore, a later  par(op)  [called by on.exit(.)] only calls par(.) with
> arguments that make sens to be changed.

Yup, but as has been pointed out there's a problem: If you change the
same parameter twice, you actually get the wrong result:

> opar<-par(cex=2)
> opar<-c(opar,par(cex=4))
> par(opar)
> par()$cex
[1] 2

which happens because

> opar
$cex
[1] 1

$cex
[1] 2

and par() sets parameters in the order it finds them. Of course one
could get the first item of each name by using

> opar[unique(names(opar))]
$cex
[1] 1

or let par(opar) do that internally, but I'm not sure that it is
really such a good idea.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._