Pass-through of unevaluated arguments
fharrell at virginia.edu writes:
Here's the situation. xYplot needs to fiddle with
arguments formula and data (which I default to
sys.frame(sys.parent()) which I believe will pass through
to xyplot OK). There are several arguments passed
through to xyplot which were the "..." arguments to xYplot.
I want to defer evaluation of these to inside xyplot where
it will evaluate the arguments with respect to the
"data" argument. A good example is the groups= variable:
xYplot(formula, data=d, groups=g)
where g might be in d or in the frame that invoked
xYplot. Using for example do.call("xyplot", list(...))
from within xYplot will result in "g not defined".
I can do something like
if(!missing(groups)) groups <- eval(substitute(groups),data)
I think eval(substitute(xyplot(...)), data, environment(formula)) will get you there if xYplot is function(formula,data,...). environment(formula) is somewhat preferable to parent.frame() in general, although they're usually the same thing. The tricky bit is when you want to mix external arguments with something computed inside xYplot. We just had this aired on R-core in a similar context, and I *think* you get by with substituting in local variables (notice that R's substitute() is not quite identical to S's).
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._