Hello, I would like to plot the following xyplot : for each date of fff (1 date per panel), bbb=f(aaa) for the two groups (ddd=1 and ddd=2) superimposed. I can do it by group (see below) but not together. I looked at http://lmdvr.r-forge.r-project.org/figures/figures.html but I haven't found what I was looking for (to be honest, I haven't understood all the examples). Any help will be welcome. Thanks in advance, Ptit Bleu. # aaa : x-axis # bbb : y-axis # ddd : group 1 or group 2 # fff : 2 different dates aaa<-rep(seq(1:100),2) bbb<-aaa*aaa*c(rep(1,50),rep(0.5,50)) ddd<-c(rep(1,50),rep(2,50)) fff<-rep(c(rep("2010-11-01",25),rep("2010-11-10",25)),2) library(lattice) # bbb as a function of aaa by date for the first group (ddd=1) x11() xyplot(bbb[ddd==1] ~ aaa[ddd==1] | fff[ddd==1], col="red", main="1") # bbb as a function of aaa by date for the second group (ddd=2) x11() xyplot(bbb[ddd==2] ~ aaa[ddd==2] | fff[ddd==2], col="blue", main="2") # bbb as a function of aaa by date for ddd=1 AND bbb as a function of aaa by date for ddd=2 in the same panels ??? -- View this message in context: http://r.789695.n4.nabble.com/xyplot-superimposed-2-groups-in-different-panels-tp3065509p3065509.html Sent from the R help mailing list archive at Nabble.com.
On 2010-11-30 06:50, PtitBleu wrote:> > Hello, > > I would like to plot the following xyplot : for each date of fff (1 date per > panel), bbb=f(aaa) for the two groups (ddd=1 and ddd=2) superimposed. > > I can do it by group (see below) but not together. > I looked at http://lmdvr.r-forge.r-project.org/figures/figures.html but I > haven't found what I was looking for (to be honest, I haven't understood all > the examples). > > Any help will be welcome. > Thanks in advance, > Ptit Bleu. > > > # aaa : x-axis > # bbb : y-axis > # ddd : group 1 or group 2 > # fff : 2 different dates > > aaa<-rep(seq(1:100),2) > bbb<-aaa*aaa*c(rep(1,50),rep(0.5,50)) > ddd<-c(rep(1,50),rep(2,50)) > fff<-rep(c(rep("2010-11-01",25),rep("2010-11-10",25)),2) > > library(lattice) > # bbb as a function of aaa by date for the first group (ddd=1) > x11() > xyplot(bbb[ddd==1] ~ aaa[ddd==1] | fff[ddd==1], col="red", main="1") > # bbb as a function of aaa by date for the second group (ddd=2) > x11() > xyplot(bbb[ddd==2] ~ aaa[ddd==2] | fff[ddd==2], col="blue", main="2") > > # bbb as a function of aaa by date for ddd=1 AND bbb as a function of aaa by > date for ddd=2 in the same panels > ??? >I *think* that you want xyplot(bbb ~ aaa | fff, groups = ddd, col = c("red", "blue")) but maybe this xyplot(bbb ~ aaa | ddd * fff) Peter Ehlers
Simply thank you. It is exactly what I wanted. Have nice day, Ptit Bleu (under snow) -- View this message in context: http://r.789695.n4.nabble.com/xyplot-superimposed-2-groups-in-different-panels-tp3065509p3066747.html Sent from the R help mailing list archive at Nabble.com.