On Thursday 24 February 2005 08:03, Petr Pikal wrote:
Dear all
I solved a problem of customised labels on strips and boxes in
bwplot by this construction.
bbb <- bwplot(zavoj ~ typmleti | pu)
bbb$condlevels$pu <- c("Povrchov? ?prava", "Bez PU")
bbb$x.limits <- c("Mleto", "Mleto a s?tov?no", "Nemleto")
bbb
but I wonder if some other easy option exist. Let say something like
bwplot(zavoj~typmleti | pu,
some advanced stuff like
box.labels=c("Mleto", "Mleto a s?tov?no", "Nemleto"),
strip.labels = c("Povrchov? ?prava", "Bez PU")
)
I think the most natural way to do this would be to change the labels
of the factor levels directly. If you don't want to do this to your
original data, you can do it on the fly as follows:
relabel <- function(x, labels)
{
stopifnot(is.factor(x))
levels(x) <- labels
x
}
y <- rnorm(100)
x <- gl(3, 1, 100)
g <- gl(2, 1, 100)
bwplot(y ~ relabel(x, c("Mleto", "Mleto a s?tov?no", "Nemleto")) |
relabel(g, c("Povrchov? ?prava", "Bez PU")))
Of course, you can also do it your way:
bwplot(y ~ x | g,
xlim = c("Mleto", "Mleto a s?tov?no", "Nemleto"),
strip = strip.custom(factor.levels =
c("Povrchov? ?prava", "Bez PU")))
This use of 'xlim' is a short-hand, the traditional way of changing
the x-axis labels is
scales = list(x = list(labels = c("Mleto", "Mleto a s?tov?no",
"Nemleto")))
Changing strip labels is more complicated if you have more than one
conditioning variable.
Deepayan