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

2007-01-30 Thread Benjamin Tyner
Thanks, that does the trick. I guess with two grouping variables it is 
best to bypass 'groups' entirely.'

Ben

Gabor Grothendieck wrote:
 Try:

 xyplot(y ~ x | f, pch = g1, col = g2, panel = function(x, y,
 subscripts, ..., pch, col)
  panel.xyplot(x, y, ..., col = col[subscripts], pch = 
 pch[subscripts])
 )


 On 1/28/07, Benjamin Tyner [EMAIL PROTECTED] 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)?

 Thanks,
 Ben

 __
 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.


__
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.


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

2007-01-30 Thread hadley wickham
On 1/28/07, Benjamin Tyner [EMAIL PROTECTED] 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.


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

2007-01-28 Thread Benjamin Tyner
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)?

Thanks,
Ben

__
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.


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

2007-01-28 Thread Gabor Grothendieck
Try:

xyplot(y ~ x | f, pch = g1, col = g2, panel = function(x, y,
subscripts, ..., pch, col)
  panel.xyplot(x, y, ..., col = col[subscripts], pch = pch[subscripts])
)


On 1/28/07, Benjamin Tyner [EMAIL PROTECTED] 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)?

 Thanks,
 Ben

 __
 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.


__
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.


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

2007-01-28 Thread talepanda
Currently, both color and plotting symbol does not change with the
grouping variable g1, that is, when
g1-rep(5:8,each=64)
,plotxy still generates same plot.

subscripts argument is useful for your purpose.

see:
panel section and details in
 ?xyplot

try:

plot-xyplot(y~x|f,
 groups=g1,
 panel=function(x,y,subscripts,groups,...){
   
panel.superpose(x,y,subscripts,groups,pch=g2[subscripts],col=g1[subscripts],...)
 })

HTH

On 1/29/07, Benjamin Tyner [EMAIL PROTECTED] 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)?

 Thanks,
 Ben

 __
 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.


__
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.