Hi,

Is there another  way to pass arguments via a vector to arbitrary functions
as in the following code example without using a series of if else
statements?

f <- test(func, x, parms, fargs1, fargs2, ...)
{
   # parms is a vector of parameters to func.
   #  ... is for use by f, not by func.
   n <- length(parms)
   if (n == 0)         y <- func(x)
  else if (n == 1)   y <- func(x, parms[1])
  else if (n == 2)   y <- func(x, parms[1], parms[2])

 # remaining body of f follows.
}

Regards,

Ernie

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to