[R] Pass-through of unevaluated arguments
fharrell at virginia.edu
Fri Jun 15 16:39:34 CEST 2001
Thanks to Deepayan Sarkar (lattice) and Paul Murrell (grid)
I have nearly finished porting the Hmisc library's xYplot
function to R. xYplot extends xyplot to allow for error bars,
bands, and a few other features. In S-Plus I extended the
Trellis function xyplot mainly by writing panel.xYplot.
In R, xyplot contains a lot of code, so I implemented xYplot
by calling xyplot from it. Things are working quite well but
I would appreciate advice on programming the most elegant
solution to passing unevaluated arguments.
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)
inside xYplot but I feel there is a more elegant approach
where I would not even have to isolate groups as a separate
argument, that experienced R programmers already know. I
would appreciate some ideas.
Frank E Harrell Jr Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
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