[R] multiple functions with three dots

Greg Snow Greg.Snow at imail.org
Fri Feb 1 19:46:21 CET 2008


You can try something like:

>a <- 1:5
>b <- 6:10
>d <- 3:7

>example <- function(x,y, z, ..., plot.dots, points.dots){
   plot.list <- list(x=x,y=y)
   plot.list <- c(plot.list,list(...), as.list(plot.dots))
   do.call(plot, plot.list)

   points.list <- list(x=x,y=z)
   points.list <- c(points.list, list(...), as.list(points.dots) )
   do.call(points, points.list)

}

>example(a,b,d, pch=0, plot.dots=list(cex=2),
points.dots=list(col='green'))

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of John Lande
> Sent: Friday, February 01, 2008 7:34 AM
> To: r-help at r-project.org
> Subject: [R] multiple functions with three dots
> 
> 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?
> 
> 
> thank you.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



More information about the R-help mailing list