Dear, 

I have a dataset with 4 subjects (see ID in example), and 4 treatment (see 
TRT in example) which are tested on 2 locations and in 3 blocs. By using 
Lattice dotplot, I made a graph that shows the raw data per location and 
per bloc. In that graph, I would like to have a reference line per bloc 
that refers to the first treatment (T1). However, I can not find how to do 
that. 

I can make a dotplot with a reference line which is the average of all 
treatments (see 2) in example). Under 3), I used the code "panel.abline 
(v=mean(x [y=="E" & TRT =="T1"],na.rm=TRUE),col="green", lty=2)" by which 
I hoped to set the reference line at 'T1', but than I get the error that 
'object TRT is missing'. 

Does anybody know a solution? 

Thanks in advance!
regards,
Barbara


EXAMPLE:
--------


library(lattice)

# 1) example dataset
#-----------------
dataset <- expand.grid (LOC=c("LOC1", "LOC2"),
                                                BLOC=c(1,2,3),
                                                ID=c("A", "B", "C", "D", 
"E"),
                                                TRT=c("T1", "T2", "T3", 
"T4"))
 
dataset$COL <- ifelse(dataset$TRT == "T1", "green",
                                        ifelse(dataset$TRT == "T2", "blue"
,
                                                        ifelse(dataset$TRT 
== "T3","orange","red"))) 
 
dataset$ID.TRT <- as.factor(paste(dataset$ID,dataset$TRT,sep="."))

dataset$OUT <- sample(50:60, 120, replace=TRUE)
 
#edit(dataset)

dataset <- dataset[order(dataset$LOC,dataset$BLOC,dataset$ID), ]

# 2) dotplot with reference line that is average of all treatments
#------------------------------------------------------------------
dotplot (ID ~ OUT | as.factor(BLOC) * LOC, 
                data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
                scales=list(alternating=FALSE,cex=0.6), 
                fill.color = dataset$COL,
                panel = function(x, y, fill.color, ..., subscripts) {
                        fill <- fill.color [subscripts]
                        panel.dotplot(x, y,  col = fill, ...)
                        panel.abline (v=mean(x [y=="E"],na.rm=TRUE),col=
"green", lty=2)
                },
                main = "Raw OUT Data",
                key = list( space ="bottom",
                                columns=2,
                                cex=0.8,
                                pch=19,
                                border=TRUE,
                                text= list(c("T1","T2","T3","T4")),
                                points = list(col=c("green","blue",
"Orange","Red"),pch=c(19,4,17,15))))

# 3) dotplot with error in reference line because 'TRT is missing'
#----------------------------------------------------------------
dotplot (ID ~ OUT | as.factor(BLOC) * LOC, 
                data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
                scales=list(alternating=FALSE,cex=0.6), 
                fill.color = dataset$COL,
                panel = function(x, y, fill.color,ID.TRT, ..., subscripts) 
{
                        fill <- fill.color [subscripts]
                        panel.dotplot(x, y,  col = fill, ...)
                        panel.abline (v=mean(x [y=="E" & TRT =="T1"]
,na.rm=TRUE),col="green", lty=2)
                },
                main = "Raw OUT Data",
                key = list( space ="bottom",
                                columns=2,
                                cex=0.8,
                                pch=19,
                                border=TRUE,
                                text= list(c("T1","T2","T3","T4")),
                                points = list(col=c("green","blue",
"Orange","Red"),pch=c(19,4,17,15))))
________________________________________________________________________
The information contained in this e-mail is for the excl...{{dropped:14}}

