[R] xyplot() and controlling panel.polygon()

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Apr 27 19:42:16 CEST 2007


On 4/26/07, Michael Kubovy <kubovy at virginia.edu> wrote:

> I'm not sure I understand.
>
> I'm trying to add a filled band to show CIs around the data (which is
> why I tried to use xYplot, where 'filled bands' have bug).
> So with these data:
>
> est <- c(1:4, 3:6, 7, 9, 11, 13, 12, 15, 18, 21)
> cond <- rep(c('a','b'), each = 8)
> grp <- rep(c('I', 'II'), each = 4, 2)
> x <- rep(c(.5, .7, .9, 1.1), 4)
> upper <- est + 1
> lower = est - 1
> data <- data.frame(est = est, x = x, cond = cond, grp = grp, upper =
> upper, lower = lower)
>
>   I'm trying to decorate this with bands:
>
> xyplot(est ~ x | cond, group = grp, data = data, type = 'b')
>
> So I'm not sure why your proposal is failing:

And in what sense exactly is it "failing"?

> my.panel.polygon <- function(..., font, fontface)
> {
>     panel.polygon(...)
> }
>
> xYplot(est ~ x | cond, group = grp, data = data, type = 'b',
>      panel = function(x, y, subscripts, groups, ...){

No, my proposal did not have 'groups' and 'subscripts' as arguments in
the custom panel function.

My point was precisely that you shouldn't have them unless you use
them, in which case, they will be simply passed on as appropriate as
part of the ... argument, whereas now they are not being passed on to
panel.xYplot at all. This should have been obvious from the error
message:

Error in panel.xYplot(x, y, , ...) : argument "subscripts" is missing,
with no default

(at least that's the error I get)

It's perfectly OK to have them as explicit arguments, but this
increases the chances of a mistake. For example, you had in your
original code (the equivalent of):

panel = function(x, y, groups, ...) {
   panel.xYplot(x, y, groups, ...)
}

which looks OK until you realize that 'groups' is not the 3rd argument
panel.xYplot().

-Deepayan

>          panel.superpose(c(x, rev(x)), c(upper, rev(lower)),
> subscripts, groups,
>              panel.groups = 'my.panel.polygon', default.units =
> 'native', ...)
>          panel.xYplot(x, y,,...)
>      }
> )
>
> _____________________________
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
> Parcels:    Room 102        Gilmer Hall
>          McCormick Road    Charlottesville, VA 22903
> Office:    B011    +1-434-982-4729
> Lab:        B019    +1-434-982-4751
> Fax:        +1-434-982-4766
> WWW:    http://www.people.virginia.edu/~mk9y/
>
>
>



More information about the R-help mailing list