Uwe, thank you very much - that was the solution I was looking for!
Best, Tal ----------------Contact Details:------------------------------------------------------- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- 2010/2/10 Uwe Ligges <lig...@statistik.tu-dortmund.de> > > > On 10.02.2010 18:58, Tal Galili wrote: > >> Hi all, >> For some reason, I would like to use functions bellow (see example code >> bellow), but instead I get the following error message: >> *Error in foo2(...) : unused argument(s) (arg3 = 3)* >> >> >> #--------------------- >> # example code >> #--------------------- >> foo1<- function(arg1,...) >> { >> print(arg1) >> foo2(...) >> foo3(...) >> } >> >> foo2<- function(arg2) >> { >> print(arg2) >> } >> >> foo3<- function(arg3) >> { >> print(arg3) >> } >> >> >> foo1(arg1 = 1, arg2 = 2, arg3 =3) >> >> #--------------------- >> >> >> I tried looking through the R Language Definition, but couldn't find >> something that helped me understand the issue (way it should happen, and >> what is a smart strategy to avoid it) >> > > With "..." you are passing arg2 and arg3 to foo2() which only expects one > argument. > > If you have rather different arguments to be passed to more than 1 > function, you may want to > > - either list all arguments as arguments in the calling function (here > foo2) or > > - restrict by calculating on > args <- list(...) > before the foo2(...) call that need to be replaced by > do.call("foo2", args) > or > > - invent two arguments for foo1 such as: > > foo1<- function(arg1, foo2args = list(), foo3args = list()) > { > print(arg1) > do.call("foo2", foo2args) > do.call("foo3", foo3args) > > } > > foo2<- function(arg2) > { > print(arg2) > } > > foo3<- function(arg3) > { > print(arg3) > } > > foo1(arg1 = 1, foo2args=list(arg2 = 2), foo3args=list(arg3 =3)) > > This way it is still possible to collect various arguments to a function > without defining all of them explicitly in the formal definition of foo1. > > Uwe Ligges > > > >> Any insight will be greatly appreciated. >> Thanks, >> Tal >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >> > [[alternative HTML version deleted]] ______________________________________________ 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.