[R] lattice graph/ panel.superpose / groups
Karin
twentestat at yahoo.com
Tue Aug 27 16:56:16 CEST 2013
Hello,
I am struggling with a lattice graph.
I want to plot points and condition on a variable called 'Method'.
For each conditional plot I have two subgroups, say: 'first'and 'second'.
I want to plot the points in a conditional graph with a different color or symbol for each subgroup.
Moreover I want to calculate within each conditional graph limits of the points together (and thus not seperately) for the subgroups. I use this code:
xyplot(Y~X|methode,
xlab="Average",
ylab="Difference ",
groups=SUBGROUP,
pch=c(1,3),
ylim=c(-0.1,0.1),
key = list(space = "right",
transparent = TRUE,
points = list(pch = c(1, 3)),
text = list(c("First", "Second"))),
panel=panel.superpose,
panel.groups=function(x,y,...){
panel.xyplot(x,y,...);
panel.abline(h=mean(y));
panel.abline(h=mean(y)+1.96*sd(y));
panel.abline(h=mean(y)-1.96*sd(y))
},
data=temp2)
However now I get lines for each subgroup within each graph, and that is not what I want.
How can I give the points for the two different subgroups a different symbol, but lines that are for both subgroups together?
Thanks in advance,
Karin
More information about the R-help
mailing list