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
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),
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]
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:
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
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
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