Re: [R] densityplot and panel.groups

From: Deepayan Sarkar <>
Date: Fri 07 Jul 2006 - 12:20:24 EST

On 7/6/06, Ken Beath <> wrote:
> I am trying to plot multiple densityplots on each panel, and using
> panel.groups to do some additional plotting (not included in the
> example) as in this example.
> library(lattice)
> thedata <- data.frame(x=rnorm(1200),class=rep(1:3,each=200,times=2),
> group=rep(1:2,each=100,times=6))
> densityplot(~x | class,groups=group,
> xlab='x',
> panel.groups = function(x,subscripts,groups,panel.number,...) {
> panel.densityplot(x=x,subscripts=subscripts,groups=groups,...)
> # other stuff here
> },
> plot.points=FALSE,
> layout=c(3,1),
> data=thedata)
> But get an "Error in panel.superpose(x, darg = darg, plot.points =
> plot.points, ref = FALSE, : formal argument "panel.groups" matched
> by multiple actual arguments" using R 2.3.1 (MacOS X 10.4.7), I think
> this worked with a previous version of R.

Among the changes in lattice from a previous version is the following:

 o instead of ignoring it as before, 'panel.xyplot' and    'panel.densityplot' now deal with a 'groups' argument appropriately    by calling 'panel.superpose'. Consequently, the default of 'panel'    in 'xyplot' etc does not need to be conditional on 'groups'.

What you are seeing is a subtle side effect: panel.densityplot, which is the default panel function in your call, does not allow a 'panel.groups' argument. You should additionally specify 'panel = panel.superpose'.

Deepayan mailing list PLEASE do read the posting guide! Received on Fri Jul 07 17:54:51 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 07 Jul 2006 - 20:15:45 EST.

Mailing list information is available at Please read the posting guide before posting to the list.