# Incompleteness in Lattice documentation (was Re: [R] lattice question: adding slopes to bwplot)

RenE J.V. Bertin rjvbertin at hotmail.com
Mon Jul 15 15:10:02 CEST 2002

```On Mon, 15 Jul 2002 08:39:05 +0100, Paul Hewson <PHewson at devon.gov.uk> wrote regarding "RE: [R]
lattice question: adding slopes to bwplot"

Hi,

Thanks. It made sense indeed: enough to discover the panel.linejoin function which does what I was looking for.

<error here>
I also understand now why I didn't find this, and associated, routine: library(help="lattice") does not list them, and on my installation, help(panel.functions) (which might) returns an error.
</error>

So what works for me is, basically:

bwplot( y~x|z, panel=function(x,y,...) {
panel.bwplot( x,y, ... )
panel.linejoin( x,y, horizontal=F )
} )

(Note the horizontal=F; by default, panel.linejoin will invert x and y. panel.linejoin(x,y,...) seems to work too, though)

8-) This added ablines (horizontal lines) to an xyplot.   The call to a panel
8-) function let me add two ablines and a loess smooth.
8-)
8-) Does that make sense?
8-)
8-) Paul
8-)
8-)
8-)
8-) xyplot(AccidentRate ~ Year | Section, data = norms.df, layout = c(2,4,8),
8-) as.table = T, between = list(x = c(1), y = c(1,1,1)),xlab = "Grey Line:
8-) Built up 'A' Roads, Green Line: Non-built-up 'A' roads (National average
8-) 1999)", ylab = "Accidents per 100 million vehicle k.m.", main = "Major 'A'
8-) roads in Devon", panel = function(x,y,...){
8-) panel.xyplot(x,y,pch = 16, col = "blue", ...)
8-) panel.abline(h = 0.91, v = 0, col = "grey", lwd = 2, lty = 2, ...)
8-) panel.abline(h = 0.25, v = 0, col = "green", lwd = 2, lty = 2, ...)
8-) panel.loess(x, y, span = 1.5, col = "blue", lwd = 3, ...)
8-) }
8-) )
8-)
8-)
8-)
8-)
8-)
8-) -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
8-) Paul Hewson     tel. (01392) 382773
8-) Data Analyst and Research Officer
8-)
8-) Road Safety Team, Environment Directorate,
8-) Devon County Council,
8-) 1st Floor, Lucombe House,
8-) County Hall
8-) Exeter EX2 4QW
8-)
8-) tel (01392) 382773   fax (01392) 382135
8-) email phewson at devon.gov.uk
8-) -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
8-) >

8-) > I'd like to add lines to the panels of a bwplot, showing (and connecting)
8-) > the means of the displayed distributions. I didn't find anything in the
8-) > documentation or the examples that suggests how to accomplish this easily.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```