[R] Lattice: merged strips?

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Jul 12 01:52:44 CEST 2008


On 7/10/08, Mike Lawrence <Mike.Lawrence at dal.ca> wrote:
> As I understand it, Duncan MacKay's solution involves simply pasting the
> factors together, as in:
>
>  |_AX_|_AY_|_BX_|_BY_|
>
>  Which isn't quite as aesthetically pleasing as what I I'm looking for:
>
>  |___A___|___B___|
>  |_X_|_Y_|_X_|_Y_|
>
>  Any further suggestions?

There is no easy way, especially if you want a general solution, but
for your specific example, here is a possible starting point:


dotplot(variety ~ yield | site * year, data = barley,
        subset = (site %in% c("Grand Rapids", "Duluth")),
        strip = function(which.given, which.panel,
                         var.name, factor.levels, ...) {
            str(list(which.given = which.given,
                     which.panel = which.panel,
                     var.name = var.name,
                     factor.levels = factor.levels, ...))
            if (which.given == 1)
                strip.default(which.given = which.given,
                              which.panel = which.panel,
                              var.name = var.name,
                              factor.levels = factor.levels, ...)
            else {
                panel.rect(0, 0.5, 1, 1, col = "#ccffcc",
                           border = "transparent")
                if (which.panel[1] == 2)
                    panel.text(0, 0.75,
                               labels = factor.levels[which.panel[2]])
            }
        })

-Deepayan



More information about the R-help mailing list