On 05/10/2010 2:23 PM, Richard R. Liu wrote:
Hi,


I have a function f<- function(..., func){ something }, where func is a
function of the form function(...).  I would like to pass func all the arguments
passed to f except the last.  I know that I can manipulate the variable number
of arguments passed to f by converting ... to a list, i.e., arglist<-
list(...).  But how do I pass func the first n-1 list items of arglist (n<-
length(arglist)), as n-1 arguments, not as one list of n-1 items?

Do you know the name of the last one? If so, just declare it as an argument to f, and it won't be caught by ... .

Do you know how many arguments there are? Then the barely documented ..1, ..2 etc might work for you.

Otherwise, convert it to a list, and use do.call(func, args), where args is the list without the last element.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to