[R] Trellis graph and two colors display

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Wed Jan 14 09:48:55 CET 2004


Hello,

I would like to display two groups of dots in different colors or style and additionnaly a linear regression for all the dots in
panel plots of a Trellis graph.  Actually to get in each panel the equivalent of:

plot(x[mois==3],y[mois==3],col="blue")
points(x[mois==9],y[mois==9],col="red")
abline(lm(y~x), col="green")

"mois" being a grouping variable and ID (see below) the conditioning variable in a data.frame of 230 rows

After several really disatreous trials, I have tried the following:

xyplot(y~x|ID,panel=function(x,y){panel.superpose(x,y,subscripts=1:230,groups=mois);panel.abline(lm(y~x),col="green")})

1/ I am not sure to have well understood what  the role of subscripts (with no default) is in the function panel.superpose and if
the values passed are appropriate here;

2/ this apparently displays all the points without changes of style between groups (neither symbols or colors).

3/ this does not allow changes in color for points display

Can anybody give me a hint on where I am wrong?

Sorry to be probably very clumpsy,

Kind regards,

Patrick Giraudoux




More information about the R-help mailing list