You say median for each panel but tapply gets medians for each variety (chartjunk IMHO). Regardless, *this case* has nothing to do with panel.abline. Add print(median.values) to your panel function would have hinted as to the missing piece.
# medians for each panel: 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") }) # medians for each variety 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 <- tapply(x, y, median) panel.abline(v=median.values, col.line="red") } ) Cheers On Wed, Jun 6, 2012 at 6:10 AM, maxbre <mbres...@arpa.veneto.it> wrote: > by considering this example from barley dataset > > #code start > > dotplot(variety ~ yield | site, data = barley, > scales=list(x=list(log=TRUE)), > layout = c(1,6), > panel = function(...) { > panel.dotplot(...) > #median.values <- tapply(x, y, median) # medians for each > variety > #panel.abline(v=median.values, col.line="red") # but this is not > working! > #panel.curve(...) # how to properly > set this? > } > ) > > #code end > > I want to plot as a reference vertical line the medians for each panel > > Ive been reading in > https://stat.ethz.ch/pipermail/r-help/2009-January/185384.html > that its not possible with panel.abline() and its probably necessary to > use panel.curve() instead; unfortunately I cant figure (manage) how, any > help for this? > > thank you > > > > > -- > 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-tp4632513.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. > [[alternative HTML version deleted]]
______________________________________________ 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.