barbara.chaves wrote:
> 
> 
> 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. 
> ...
> 

Thanks a lot for the nice self-contained example which certainly has cost
you some time. A bit of nitpicking: You could have improved it a little by
removing decorative stuff and using a lower degree of indentation to avoid
ugly line breaks in email. 

You were close by, but I believe that you ran into the trap of believing
that the dot in ID.TRT is something special in variable names as it is in c
or Pascal. The dot in names has sometimes a meaning for functions (try
methods("print")) but it is not possible to "get a part of it" in panel.dot. 

The workaround is simple: pass TRT, not ID.TRT. Everything else was fine,
some minor modifications were added.

Dieter

# Begin code
dataset <- expand.grid (
      LOC=c("LOC1", "LOC2"),
      # Better make it a factor immediately to avoid surprises later
      BLOC=as.factor(c(1,2,3)),
      ID=c("A", "B", "C", "D","E"),
      TRT=c("T1", "T2", "T3","T4"))
# replaced nested ifelse
dataset$COL <- factor(dataset$TRT,labels=c("green", "blue","orange","red"))

dataset$ID.TRT <- as.factor(paste(dataset$ID,dataset$TRT,sep="."))
dataset$OUT <- sample(50:60, 120, replace=TRUE)

# removed "as.factor". Corrected TRT
dotplot (ID ~ OUT | BLOC * LOC,
  data=dataset,pch=c(19,4,17,15),
  TRT = dataset$TRT,
  fill.color = dataset$COL,
  panel = function(x, y, TRT, ..., subscripts)
  {
    panel.dotplot(x, y,fill=fill.color,  ...)
    panel.abline (v=mean(x [y=="E" & TRT =="T1"],na.rm=TRUE),col="green",
lty=2)
  })
   

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-dotplots-tp3067130p3067382.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org 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.

Reply via email to