Let us walk through my problem step by step:

1.
print(xyplot(yield ~ variety | site,groups=year,data=barley))
2.
print(xyplot(as.formula("yield ~ variety | site"),groups=year,data=barley))

The above two statements work, the next one does not work

3.
print(xyplot(as.formula("yield ~ variety | site"),groups=parse (text="year"),data=barley))

But the following one works

4.
arglist<-list(as.formula("yield ~ variety | site"),groups=parse (text="year"),data=barley)
print(do.call("xyplot",arglist))


why does 3 not work and 4 work?
Is there a way of coercing the string "year" into something which can directly be used in
3 as the argument used with groups= ???


The next one

print(xyplot(as.formula("yield ~ variety | site"),groups=eval(parse (text="year")),data=barley))

also works, but in this case the groups expression is evaluated before xyplot is applied,
and I think this is bad style (at least, if not worse).


On Sep 30, 2009, at 1:20 PM, Deepayan Sarkar wrote:

xyplot(Sepal.Length ~ Petal.Length, iris, groups = ~Species)

______________________________________________
R-help@r-project.org 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.

Reply via email to