[R] Types in grouped multi-panel (lattice) xyplot

Aaron Arvey aarvey at cs.ucsd.edu
Thu Apr 10 21:51:52 CEST 2008


Apologetic prologue: I've looked through the mailing list for an answer to 
this (since I'm sure it's trivial) but I have not been able to find a fix.

So the problem is that I want each group to have a different type of plot. 
"Probes" should be points and "Segments" should be lines (preferably using 
the segment plot command, but I've just been trying -- unsuccessfully -- 
to get lines to work).

To be exact, the data looks like:

loc      val   valtype      mouse
1428  0.1812367 Probes      2
1439 -0.4534155 Probes      2
1499 -0.4957303 Probes      2
1559  0.2448838 Probes      2
1611 -0.2030937 Probes      2
1788 -0.2235331 Probes      2
1428 0.5        Segment     2
1439 0.5        Segment     2
1499 0.5        Segment     2
1559 0.5        Segment     2
1611 0.5        Segment     2
1788 0.5        Segment     2
1428  0.1812367 Probes      1
1439 -0.4534155 Probes      1
1499 -0.4957303 Probes      1
1559  0.2448838 Probes      1
1611 -0.2030937 Probes      1
1788 -0.2235331 Probes      1
1428 0.5        Segment     1
1439 0.5        Segment     1
1499 0.5        Segment     1
1559 0.1        Segment     1
1611 0.1        Segment     1
1788 0.1        Segment     1


   * loc is the x-axis location
   * val is the y-axis value
   * valtype is equal to "which" had I been smart and used make.groups
   * mouse is the 'cond' variable


The plot command I'm currently using is,

xyplot(val ~ loc | mouse, data = df,
             groups=valtype
             aspect=0.5, layout=c(3,3),
             lty=0, lwd=3, type="p",
             col=c("black", "blue"),
             as.table = TRUE)

which gives me black and blue points for the probes/segments (I've infered 
alphabetical order for the groups colors).  When I change the type to 
c("p", "l"), I get

xyplot(val ~ loc | mouse, data = df,
             groups=valtype
             aspect=0.5, layout=c(3,3),
             lty=0, lwd=3, type=c("p","l"),
             col=c("black", "blue"),
             as.table = TRUE)


I get the exact same plot.  I've tried using a few of the panel functions 
I found on the list (I was particularly hopeful for 
http://tolstoy.newcastle.edu.au/R/help/06/07/30363.html) but I've either 
been misusing them, or they are not right for what I want to do.

If anyone knows how to get points and lines in the same panel for the two 
different groups (probes/segments), I would love to hear about it.

If you further know how to use the 'segment' plot in panels for the 
segments, I would really love to hear about it.

Thanks in advance!

Aaron



More information about the R-help mailing list