Re: [R] lattice: two grouping variables, one controls 'col', the other 'pch'

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue 30 Jan 2007 - 18:05:07 GMT

On 1/28/07, Benjamin Tyner <btyner@stat.purdue.edu> wrote:
> Say I have
>
> library(lattice)
>
> x<-runif(256)
> y<-runif(256)
> f<-gl(16,16)
> g1<-rep(1:4,each=64)
> g2<-rep(1:4,times=64)
>
> plot<-xyplot(y~x|f,
> groups=g1,
> pch=as.character(1:4),
> panel=function(x,y,subscripts,groups,...){
> panel.superpose(x,y,subscripts,groups,...)
> })
>
> print(plot)
>
> Currently, both color and plotting symbol change with the grouping
> variable g1. What is the best way to have color change with g1, but
> plotting symbol change with g2 (or vice versa)?

Another option is to use ggplot:

install.packages("ggplot")
library(ggplot)
qplot(x, y, facet=. ~ f, size=g1, colour=g2)



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 Jan 31 06:54:16 2007

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 Tue 30 Jan 2007 - 20:30:30 GMT.

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