Bill Dunlap wrote: > On Sun, 2 Jul 2006, Gregor Gorjanc wrote: > >> Yes, this works. >> >> Thanks Gabor! >> >> Gabor Grothendieck wrote: >>> That's because you are passing the argument twice. Try this: >>> >>>> foo1 <- function(x, ...) >>> + { >>> + L <- list(...) >>> + if (is.null(L$decreasing)) L$decreasing <- TRUE >>> + do.call(order, c(list(x), L)) >>> + } >>>> foo1(c(5, 2, 3, 4), decreasing=FALSE) >>> [1] 2 3 4 1 > > How does this differ from > foo2 <- function(x, ..., decreasing=TRUE) > order(x, ..., decreasing = decreasing) > ?
I agree, but I wanted to learn ... argument in a more general way. That was just an example - not a good one as you have showed. >> x<-c(5,2,3,4) >> identical(foo2(x), foo1(x)) > [1] TRUE >> identical(foo2(x,decreasing=F), foo1(x,decreasing=F)) > [1] TRUE >> identical(foo2(x,decreasing=T), foo1(x,decreasing=T)) > [1] TRUE -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel