a new session of R with the following sessionInfo() R version 2.15.0 (2012-03-30) Platform: i386-pc-mingw32/i386 (32-bit)
locale: [1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252 [3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C [5] LC_TIME=Italian_Italy.1252 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: [1] latticeExtra_0.6-19 RColorBrewer_1.0-5 lattice_0.20-6 loaded via a namespace (and not attached): [1] grid_2.15.0 tools_2.15.0 this is the code I run #start library(lattice); library(latticeExtra) #example with user function addLine<- function(a=NULL, b=NULL, v = NULL, h = NULL, ..., once=F) { tcL <- trellis.currentLayout() k<-0 for(i in 1:nrow(tcL)) for(j in 1:ncol(tcL)) if (tcL[i,j] > 0) { k<-k+1 trellis.focus("panel", j, i, highlight = FALSE) if (once) panel.abline(a=a[k], b=b[k], v=v[k], h=h[k], ...) else panel.abline(a=a, b=b, v=v, h=h, ...) trellis.unfocus() } } dotplot(variety ~ yield | site, data = barley, scales=list(x=list(log=TRUE)), layout = c(1,6), panel = function(x,y,...) { panel.dotplot(x,y,...) median.values <- median(x) panel.abline(v=median.values, col.line="red") }) mean.values<-tapply(barley$yield, barley$site, mean) addLine(v=log10(mean.values), once=TRUE, col="blue") # example with panel.abline dotplot(variety ~ yield | site, data = barley, scales=list(x=list(log=TRUE)), layout = c(1,6), panel = function(x,y,...) { panel.dotplot(x,y,...) mean.values <- mean(x) #omitted in second run panel.abline(v=mean.values, col.line="red") #omitted in second run median.values <- median(x) panel.abline(v=median.values, col.line="blue") }) #end this are the two different results I’ve got: example with user defined function http://r.789695.n4.nabble.com/file/n4632706/example_with_user_function.png example with panel.abline http://r.789695.n4.nabble.com/file/n4632706/example_with_panel_abline.png and now I’m really confused of what I’m doing and seeing… -- View this message in context: http://r.789695.n4.nabble.com/how-to-add-a-vertical-line-for-each-panel-in-a-lattice-dotplot-with-log-scale-tp4632513p4632706.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.