From ligges at statistik.uni-dortmund.de  Wed Oct 27 11:00:28 2004
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Wed Oct 27 11:00:24 2004
Subject: [Rd] Re: [R] persp(), scatterplot3d(), "..." argument
In-Reply-To: <1098866288.16776.45.camel@biol102145.oulu.fi>
References: <a0600200ebda3cb456654@[139.166.242.29]>	<417F488C.7000405@statistik.uni-dortmund.de>	<1098862790.16776.29.camel@biol102145.oulu.fi>	<417F5844.4040206@statistik.uni-dortmund.de>
	<1098866288.16776.45.camel@biol102145.oulu.fi>
Message-ID: <417F63AC.7090309@statistik.uni-dortmund.de>

Jari Oksanen wrote:

> On Wed, 2004-10-27 at 11:11, Uwe Ligges wrote:
> 
>>Jari Oksanen wrote:
>>
>>
>>>On Wed, 2004-10-27 at 10:04, Uwe Ligges wrote:
>>>
>>>
>>>This is a larger problem if 
>>>1. one of the underlying functions does not have "..."
>>>2. you want to relay arguments to two or more underlying functions, and
>>>3. you don't want to list all possible arguments in your function
>>>definition, since it is long enough already.
>>>
>>>The solution is still there, but it is (black) magic. For instance,
>>>'arrows' does not have "...", so you must add them with this magical
>>>mystery string:
>>>
>>>formals(arrows) <- c(formals(arrows), alist(... = ))
>>
>>
>>You don't need it for simple things like:
>>
>>   foo <- function(...){
>>       plot(1:10)
>>       arrows(1,1,7,7,...)
>>   }
>>
>>foo(lwd=5) # works!
>>
> 
> That's why I had point 2 above: it really would work with simpler
> things. However, the following may fail:
> 
> 
>>parrow <- 
> 
> function (x, y, ...)
> {
>     plot(x, y, ...)
>     arrows(0, 0, x, y, ...)
>     invisible()
> }
> 
>>parrow(runif(10), runif(10), col="red") # works
>>parrow(runif(10), runif(10), col="red", pch=16)
> 
> Error in arrows(0, 0, x, y, ...) : unused argument(s) (pch ...)
> 
> Adding formals would help.
> 
>>As always, useful patches are welcome.
>>
> 
> 
> I don't know if this counts as a "useful patch", but it is patch anyway:
> 
> diff -u2r old/arrows.R new/arrows.R
> --- old/arrows.R        2004-10-27 11:32:25.000000000 +0300
> +++ new/arrows.R        2004-10-27 11:32:53.000000000 +0300
> @@ -1,5 +1,5 @@
>  "arrows" <-
>  function (x0, y0, x1, y1, length = 0.25, angle = 30, code = 2,
> -    col = par("fg"), lty = NULL, lwd = par("lwd"), xpd = NULL)
> +    col = par("fg"), lty = NULL, lwd = par("lwd"), xpd = NULL, ...)
>  {
>      .Internal(arrows(x0, y0, x1, y1, length = length, angle = angle,
> 

[moved to r-devel!]

At least a patch for the docs is missing (pointing out that passing args 
through "..." won't have any effect) - and depending on what R-core 
thinks about this issue.

Uwe Ligges



> cheers, jari oksanen


[Rd] Re: [R] persp(), scatterplot3d(), "..." argument
Uwe Ligges