how do I change the text displayed in the strips of lattice plots? example: suppose I have a data frame test consisting of 3 columns
x
[1] 1 2 3 4 5 6 7 8 9 10
y
[1] "A" "A" "A" "A" "A" "B" "B" "B" "B" "B"
a
[1] -1.9952066 -1.7292978 -0.8789127 -0.1322849 -0.1046782 0.4872866
[7] 0.5199228 0.5626998 0.6392686 1.6604549
a normal call to a lattice plot
xyplot(a~x | y,data=test)
will give the plot with the Text 'A' and 'B' on the strips
How can I get different texts written on the strips?
An attept with another character vector
z
[1] "a" "a" "a" "a" "a" "b" "b" "b" "b" "b"
and a call to strip.custom()
xyplot(a~x | y,data=test,strip=strip.custom(var.name=z))
does not give the desired result.
In reality it is an internationalization problem.
I think what you want can be obtained by:
z <-c( "a" , "b" ) # Same number of values as there are panels
xyplot(a~x | y,data=test,strip=strip.custom(factor.levels=z))
If you make your character vector a factor then you can just change the levels:
> xyplot(a~x | y,data=test) # your plot
> test$y=as.factor(test$y) # convert y to factor
> xyplot(a~x | y,data=test) # should be identical
> levels(test$y)=c("Argh","Boo") # change the level labels
> xyplot(a~x | y,data=test) # new panel labels!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With