On 8/30/07, Mike Lawrence <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Tinkering with a wrapper for xyplot that will help me plot a bunch of
> plots in a data analysis I'm doing and I ran into an odd error that
> I'm guessing is a scope issue. Here's a very simple version of the code:
It's indeed a scoping issue. For writing wrappers, the best solution
I've been able to come up with involves match.call() and
eval.parent(). See lattice:::dotplot.formula for a template.
If you really want to do it your way, try changing the environment of
the formula:
do.xyplot = function( plot.formula, data.frame, plot.groups){
print(plot.groups)
environment(plot.formula) <- environment() # new
xyplot(
plot.formula
,data = data.frame
,groups = eval(plot.groups)
)
}
-Deepayan
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.