[R] Variable number of arguments to function

Gabor Grothendieck ggrothendieck at gmail.com
Thu May 25 19:26:17 CEST 2006


You can mix ... and other arguments. See, for example, anova.glm.

On 5/25/06, Michael Prager <Mike.Prager at noaa.gov> wrote:
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list