Hi. I'm embarking on my first attempt at creating my own panel function for lattice graphics, and despite all of my online research and pouring through the documentation, I cannot figure out how to solve my particular problem. Hopefully, a generous fellow R user can help.

I have some data that is split into two groups: some "actual" data, and some simulated data, generated from several different models. The actual data come from two different datasets (calibration and holdout), and the simulations were calibrated on each data set under the various models.

What I want to do is create a boxplot on the simulated data, and superimpose a line representing the actual data. This plot would condition on dataset and model. While the simulated data various across model and dataset, the actual data varies only across dataset and is common for all models.

My approach was to use panel.superpose, and create a panel function that, depending on the group.number, calls either panel.bwplot or panel.lines. Like this:

panel.custom.plot <- function (..., group.number) {

        if (group.number == 1) {
                panel.bwplot(...)
        } else {
                panel.lines(...)
        }
}

obj <- bwplot(p ~ as.factor(count) | dataset + model, data = data.frame,
        panel = panel.superpose,
        groups = group,
       panel.groups = panel.custom.plot
}


When I do this, I see the bwplot, but I cannot see the lines. It is as though the data isn't being passed through.

Can someone help me get started with this, and instruct me a little bit more on how arguments are passed from trellis functions to the panel functions?

I did consider a second approach, where I don't use panel.superpose or groups at all, but pass the actual.calib and actual.hold datasets as parameters to a panel function. This panel function would call panel.bwplot, and then, depending on the value of dataset, add lines for either actual.calib or actual.hold. But I do not know how to let the panel function know what level of a conditioning variable is being plotted in a particular panel.

Thanks in advance for any help you can provide,

Michael



Michael Braun
Homer A. Burnell Career Development Professor
        and Assistant Professor of Management Science (Marketing Group)
MIT Sloan School of Management
One Amherst St., E40-169
Cambridge, MA 02139
(617) 253-3436
[EMAIL PROTECTED]

______________________________________________
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.

Reply via email to