[R] Messing with the "..." argument

Steve Lianoglou slianoglou at gmail.com
Thu Feb 12 20:34:25 CET 2009


Hi all,

Sorry if this is documented somewhere, but trying to search and google for 
ways to alter my "..." argument is having me chasing my tail.

Is there someway that I can manipulate the elements in "..."? 
Specifically I'd like to use certain vars in "...", then remove them 
from "..." and pass the rest of "..." to another function.

Here's a short example: I'm adding more functionality to a generic 
method by defining how it works on a new class "MyClass":

setMethod('existingFunction', 'MyClass', function (object, ...) {
  vars <- list(...)
  doSomethingWith(vars$myCustomVar)
  
  # now I want to pass the rest of the vars down to another function,
  # let's say some plotting function, so I'd like to remove
  # `myCustomVar` from "...", keep the rest of the vars and just
  # pass the valid "..." elements down through the call chain
  
  doSomePlot(somethingSane, ...)
})

Currently the `doSomePlot` that's called does fine until it passes the
rest of it's vars to the "real" plot method, at which point I'll get
a warning like:

Warning messages:
1: In plot.window(...) : "myCustomVar" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "myCustomVar" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
  "myCustomVar" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
  "myCustomVar" is not a graphical parameter
5: In box(...) : "myCustomVar" is not a graphical parameter
6: In title(...) : "myCustomVar" is not a graphical parameter

Depending on what the name of myCustomVar is, this can work even with
the warnings, which is passable. It might also bail if myCustomVar
happens to share a name with a real plotting var, but has an illegal
value for it.

Anyway, while there are ways it can work in this case, I'm just wondering
if I can remove elements from "..." and side-step these warning/error issues
altogether.

Since "vars <- list(...)" works to create a list of arguments from "...",
I'm guessing there must be a way to take an already existing list variable
and turn its name/value pairs into an appropriate "..." object?

Thanks for any help,
-steve




More information about the R-help mailing list