[R] modify "..." (optional args)

Pascal A. Niklaus pascal.niklaus at ieu.uzh.ch
Fri Oct 7 10:39:31 CEST 2011


Hi all,

Is there a way to modify the optional arguments (...) passed to a 
function, so that these can be passed in modified form to a subsequent 
function call? I checked "Programming with Data" but could not find a 
solution there.

What I'd like is something along these lines:

test <- function(x,y,...) {
   if(!hasArg(xlab)) { ___add xlab to ...___ }
   if(hasArg(xlab)) { ___remove xlab from ...___ }  # alternative

   plot(x,y,...)
}

Of course, I could use separate calls, like

if(hasArg(xlab)) plot(x,y,...) else plot(x,y,xlab="label",...)

but this gets complicated if there is more than one such case to consider.

Thanks

Pascal

-- 

Pascal A. Niklaus
Institute of Evolutionary Biology and Environmental Studies
University of Zurich
Winterthurerstrasse 190
CH-8057 Zurich / Switzerland



More information about the R-help mailing list