Re: [R] lattice and several groups

From: hadley wickham <h.wickham_at_gmail.com>
Date: Wed 30 Aug 2006 - 07:47:37 EST

> I would like to use the lattice library to show several groups on
> the same graph. Here's my example :
>
> ## 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)

It's pretty easy to do this with ggplot:

install.packages("ggplot", repos="http://ggobi.org/r/") library(ggplot)
qplot(x, val, data=df, shape=f2, colour=f1)

Hadley



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 07:54:22 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 Thu 31 Aug 2006 - 08:23:28 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.