Re: [R] multiple functions with three dots

2008-02-01 Thread Greg Snow
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
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of John Lande
 Sent: Friday, February 01, 2008 7:34 AM
 To: r-help@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@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.
 

__
R-help@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.


Re: [R] multiple functions with three dots

2008-02-01 Thread Jim Lemon
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

__
R-help@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.