[Rd] Changing "..." inside a function: impossible? desirable?

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Tue Dec 17 19:08:06 2002


This is was something like a request for your comments, thoughts
on the topic...

Many of you will know that the "..." (aka \dots) argument is
very useful for passing ``further graphical parameters'', 
but can be a pain when itself is passed to too many plotting
functions inside your own function.
An artificial example being

  myplot <- function(x,y, ...) {

   plot(0:1, 0:1, type = "n", axes = FALSE)

   result <-  <<do stuff with x,y>>

   points(result, ...)
   axis(1, ...)
   axis(2, ...)
   title(...)
  }

It's clear that some things in "..." can be passed to title() and
some to axis(), etc.
Of course the above is really silly, but I have a situation
where I'd like to see if something, say, `myarg' is part of "..."  
{piece of cake easy, see below} but then I want to  *eliminate*
it from "..." such that I can pass "..." down to other functions
which would want to see a `myarg' argument.

Something like

if("myarg" %in% (naml <- names(list(...)))) {
   ## ok, it's there, take it out
   marg <- list(...)$ marg

   ## what I now would like is  

   ...  <-  unlist( list(...)["myarg" != naml] )
}


BTW: one relatively ugly workaround is to use the above *list*
     say  nlist <- list(...)["myarg" != naml]
     and do all subsequent call where I'd had "..." as
     do.call( <funname> ,  c(list( <<other args to funnname>> ), nlist))
but this really obfuscates the code horrendously.

PS: 
    I know that using a  pars = list(.) argument instead of "..."
    is another alternative (that we have been using) as well,
    but lets assume this can't be done, because of compatibility reasons.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><