xyplot : superimposed 2 groups in different panels

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

xyplot : superimposed 2 groups in different panels

PtitBleu
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
???
Reply | Threaded
Open this post in threaded view
|

Re: xyplot : superimposed 2 groups in different panels

Peter Ehlers
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

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: xyplot : superimposed 2 groups in different panels

PtitBleu
Simply thank you.
It is exactly what I wanted.
Have nice day,
Ptit Bleu (under snow)