[R] Variable number of arguments to function

Michael Prager Mike.Prager at noaa.gov
Thu May 25 19:07:46 CEST 2006


Dear R List,

I have used ... to pass a varying number of arguments to a function.  
The function takes parts of specialized data objects (they happen to be 
lists) and makes comparative graphs and analyses.  The code shell looks 
like this:

models.compare <- function(...) {
   ## Get the data objects passed
   models <- list(...)
   nmodels <- length(models)
   ## Get names of models:
   modelnames <- as.character(substitute(c(...))[-1])
   ##### much code omitted here #####
}


Now I would like to pass a few named arguments to the function as well, 
to control how it prints, plots, makes files.  I am seeking advice on 
the simplest way to do this (along with the varying number of data 
arguments).

Mike

-- 
Michael H. Prager
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
Beaufort, North Carolina 28516 USA



More information about the R-help mailing list