Re: [R] ... and parameter checking

About this list Date view Thread view Subject view Author view

Paul Gilbert (pgilbert@bank-banque-canada.ca)
Fri, 17 Dec 1999 11:20:04 -0500



>when writing a wrapper function, I would like to be able to pass additional
>arguments to more than one function inside, e.g.

The only way I know how to do this is something like

  density.panel <- function(x, na.rm=TRUE, density.args=NULL, ...){
     usr <- par("usr")
     on.exit(par(usr))
     par(usr = c(usr[1:2], 0, 1) )
     arglist <- append(list(x, na.rm=na.rm, ), density.args)
     lines( do.call("density", arglist), ... )
  }

and then call it like

  density.panel(x, col="red", density.args=list(kernel="rectangular"))

Please note, I haven't tested this example so there may be small errors, but
this approach works generally. If someone know a more elegant approach I would
like to hear about it.

Paul Gilbert

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b3 on Tue 04 Jan 2000 - 13:34:03 EST