[R] panel function in a conditioned lattice graphic

Anthony Darrouzet-Nardi anthony at darrouzet-nardi.net
Sat May 29 22:24:03 CEST 2004


I'm trying to use plotting character to encode the variable "block" 
from my dataset in a conditioned lattice graphic (R 1.9.0 on Mac OS 
10.3.3). The data I'm using is the dataframe "dryoutcover" which is 
here (4k):

http://anthony.darrouzet-nardi.net/downloads/dryoutcover.Rdata

The code that generates my graphic almost correctly is as follows:

xyplot(coversage ~ dryout | year,
	data=dryoutcover,
	panel = function(x,y) {
		panel.lmline(x,y)
		one <- dryoutcover$block==1
		two <- dryoutcover$block==2
		thr <- dryoutcover$block==3
		fou <- dryoutcover$block==4
		fiv <- dryoutcover$block==5
		six <- dryoutcover$block==6
		grid.points(x[one], y[one], pch=49)
		grid.points(x[two], y[two], pch=50)
		grid.points(x[thr], y[thr], pch=51)
		grid.points(x[fou], y[fou], pch=52)
		grid.points(x[fiv], y[fiv], pch=53)
		grid.points(x[six], y[six], pch=54)
		}
	)

The only thing wrong is that this does not correctly encode blocks 5 
and 6, which only appear in the third year of the study, 2003 (the 
third panel of the graphic). It instead labels blocks 5 and 6 as 
blocks 1 and 2 as if another year had started over (but on the same 
panel). For example, the point farthest to the right in the third 
panel says "2" when I want it to say "6." When I do not condition by 
year, it correctly displays blocks 5 and 6.

How can I correct this in the conditioned graphic?

Anthony Darrouzet-Nardi




More information about the R-help mailing list