Skip to content
Back to formatted view

Raw Message

Message-ID: <385A62B4.1EF9C0D7@bank-banque-canada.ca>
Date: 1999-12-17T16:20:04Z
From: Paul Gilbert
Subject: ... and parameter checking

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