Re: [Rd] Test for argument in ...

2006-07-02 Thread Gregor Gorjanc
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

Re: [Rd] Test for argument in ...

2006-07-02 Thread Gregor Gorjanc
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),

Re: [Rd] Test for argument in ...

2006-07-01 Thread Gabor Grothendieck
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 On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTED]

Re: [Rd] Test for argument in ...

2006-07-01 Thread Gregor Gorjanc
Hi, Gabor Grothendieck wrote: > Try this: > >> f <- function(...) if (!is.null(list(...)$arg1)) cat("arg1 found\n") >> else cat("arg1 not found\n") >> f(arg1 = 3) > arg1 found >> f(arg2 = 3) > arg1 not found Actually it is not OK. Bellow is simplified example that shows, what I would like to do:

Re: [Rd] Test for argument in ...

2006-07-01 Thread Gregor Gorjanc
Gabor Grothendieck wrote: > Try this: > >> f <- function(...) if (!is.null(list(...)$arg1)) cat("arg1 found\n") >> else cat("arg1 not found\n") >> f(arg1 = 3) > arg1 found >> f(arg2 = 3) > arg1 not found Thanks! Use of list(...) really helps me here. > On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTE

Re: [Rd] Test for argument in ...

2006-07-01 Thread Gabor Grothendieck
Try this: > f <- function(...) if (!is.null(list(...)$arg1)) cat("arg1 found\n") else > cat("arg1 not found\n") > f(arg1 = 3) arg1 found > f(arg2 = 3) arg1 not found On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote: > Hello! > > Say I have a function foo1, which has argument ... to pass vario

[Rd] Test for argument in ...

2006-07-01 Thread Gregor Gorjanc
Hello! Say I have a function foo1, which has argument ... to pass various arguments to foo2 i.e. foo1 <- function(x, ...) { foo2(x, ...) } Say that foo2 accepts argument arg1 and I would like to do the following: - if foo1 is called as foo1(x) then I would like to assign some value to arg1 ins