[R] ... and parameter checking

Paul Gilbert pgilbert at bank-banque-canada.ca
Fri Dec 17 17:20:04 CET 1999

>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")
     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 at stat.math.ethz.ch

More information about the R-help mailing list