maechler@stat.math.ethz.ch
1999-Sep-06 09:04 UTC
matplot(... panel.first=..) fails <==> dealing with "..." (PR#267)
Maybe, the following is not a bug in the strict sense,.... The following code shows what the effect : p1 <- function(...) plot.default(...) p2 <- function(...) { n <- names(list(...)); plot.default(...) } par(mfrow=c(2,2)) p1(1:10, panel.first = grid(10,10)) # works okay (grid drawn) p2(1:10, panel.first = grid(10,10)) # doesn't draw the grid A consequence of this is that the panel.first argument (of plot.default) doesn't work with matplot() [well, matplot()'s doc doesn't claim it should, but still ------- The real questions behind are: 1a) Why is "..." changed at the moment that I do list(...) 1b) is this basic behavior desirable / changeable .... 2) How can one work around? {save "..." to something else, first? or explicitly save panel.first?} ----------------------------- R versions, both 0.64.2 and 0.65.0 (probably all R versions) Version: platform = sparc-sun-solaris2.5 arch = sparc os = solaris2.5 system = sparc, solaris2.5 status status.rev = 0 major = 0 minor = 64.2 year = 1999 month = July day = 3 language = R Search Path: .GlobalEnv, Autoloads, package:base -- Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
1999-Sep-06 12:25 UTC
matplot(... panel.first=..) fails <==> dealing with "..." (PR#267)
maechler@stat.math.ethz.ch writes:> Maybe, the following is not a bug in the strict sense,.... > > The following code shows what the effect : > > p1 <- function(...) plot.default(...) > p2 <- function(...) { n <- names(list(...)); plot.default(...) } > > par(mfrow=c(2,2)) > p1(1:10, panel.first = grid(10,10)) # works okay (grid drawn) > p2(1:10, panel.first = grid(10,10)) # doesn't draw the grid...> The real questions behind are: > > 1a) Why is "..." changed at the moment that I do list(...) > 1b) is this basic behavior desirable / changeable ....That's a result of lazy evaluation. plot.default is really playing with fire, the way it is currently written. list(...) will force evaluation of the promises which in turn causes grid() to be called too early. I don't think it is desirable to change this behavior (well, Robert wants us to consider eager evaluation, but that would cause the construction to stop working in all cases!)> 2) How can one work around? > {save "..." to something else, first? > or explicitly save panel.first?} >Neither of the above, because the object is to access "..." without forcing evaluation of its contents. One can do things like> p2function (...) { n <- names(match.call(expand.dots = F)[["..."]]) plot.default(...) } Or, one can modify plot.default to take panel.first as an *unevaluated* expression (mode "call" or "expression"), and do an explicit eval(panel.first). But then you'd have to do p2(1:10, panel.first = quote(grid(10,10))) # or expression( ) -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._