# [R] lattice and several groups

From: Laurent Rhelp <laurentRhelp_at_free.fr>
Date: Wed 30 Aug 2006 - 06:18:07 EST

## the data

```f1 <- factor(c("mod1","mod2","mod3"),levels=c("mod1","mod2","mod3"))
f1 <- rep(f1,3)
f2 <- factor(rep(c("g1","g2","g3"),each=3),levels=c("g1","g2","g3"))
df <- data.frame(val=c(4,3,2,5,4,3,6,5,4), x=rep(c(1,2,3),3),f1=f1,f2=f2)
#############################################################
```
library(lattice)

para.liste <- trellis.par.get()
superpose.symbol <- para.liste\$superpose.symbol superpose.symbol\$pch <- c(1,2,3)
trellis.par.set("superpose.symbol",superpose.symbol)

# Now I can see the group according to the f1 factor (with a different
symbol for every modality)
xyplot( val~x,

```        data=df,
group=f1,
auto.key=list(space="right")
)

```

# or I can see the group according to the f2 factor
xyplot( val~x,

```        data=df,
type="l",
group=f2,
auto.key=list(space="right",points=FALSE,lines=TRUE)
)

```

How can I do to highlight both the f1 and f2 factors on one panel with the legends, using the lattice function ?

Thanks

R-help@stat.math.ethz.ch 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. Received on Wed Aug 30 06:12:46 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 30 Aug 2006 - 12:23:53 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.