Re: [R] recursive do.call

2011-03-14 Thread Felix Andrews
It is complicated if the argument list is all mixed in together as in your example. You would have to look up argument lists for possible S3 methods (e.g. 'digits' is an argument to print.default), and then there is S4 to think about. Also, can arguments be matched by partial names? Can they be

Re: [R] recursive do.call

2011-03-14 Thread Jeroen Ooms
Hmmm I was hoping there would be a more natural way to do it. For example, if you actually try to call the first function with all arguments: lm(formula=dist~speed, digits=3, data=cars) R will match whatever it can, and give you a warning with the names of remaining unmatched arguments. The only

Re: [R] recursive do.call

2011-03-14 Thread Thomas Lumley
On Tue, Mar 15, 2011 at 9:05 AM, Jeroen Ooms jeroeno...@gmail.com wrote: Hmmm I was hoping there would be a more natural way to do it. For example, if you actually try to call the first function with all arguments: lm(formula=dist~speed, digits=3, data=cars) R will match whatever it can, and

Re: [R] recursive do.call

2011-03-14 Thread Gene Leynes
I'm not 100% sure of your problem... It seems that you may want to consider these functions rapply mapply Also, making a separate wrapper function for what you want to do. E.g.: ModelPrinterFun = function(dat){ model = glm(dist~speed, data=dat) print(coef(model), digits=3) }

Re: [R] recursive do.call

2011-03-14 Thread Jeroen Ooms
I see what you are saying. The application I am working with is making convenient single-call (user) interfaces for R functions, and I don't want to write a wrapper for every possible combination (like Gene suggested below). If we don't consider the ... arguments for a second, and only consider

[R] recursive do.call

2011-03-13 Thread Jeroen Ooms
I would like to define a recursive equivalent to call or do.call, which takes a vector of multiple function names and 'chains' them, by greedy matching of arguments down the chain. For example, I would like to be able to do: rec.do.call(c(glm,coef,print), list(formula=dist~speed, digits=3,