[R] multiple functions with three dots

Jim Lemon jim at bitwrit.com.au
Sat Feb 2 07:03:27 CET 2008


John Lande wrote:
> Dear all,
> 
> I am creating functions with the "three dot" strategy. I wold like to have
> suggestion when writing multiple functions that calls multiple functions
> with "...".
> 
> I will give you a couple of example:
> 
> 
>>a=1:5
>>b=6:10
>>d=3:7
> 
> 
>>example=function(x,y, z, ...){
> 
>    plot(x,y, ...)
>    points(x,z, ...)
> 
> }
> 
> 
>>example(a,b,d)
> 
> 
> how can I set different parameters for points and plot functions? for
> example in plot I want to have bigger dots (lwd=3), while in the points I
> want to have green dots.
> 
> any suggestion?
> 
Hi John,
There are probably better solutions to this problem, but I usually add 
explicit arguments like this:

example<-function(x,y,z,y.lwd,z.col,...) {
  ...
  plot(x,y,lwd=y.lwd,...)
  points(x,z,col=z.col)
  ...
}

Jim



More information about the R-help mailing list