[R] R graph strip in Greek Letters
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Fri Apr 21 18:36:58 CEST 2006
zj yang wrote:
> Hi all,
>
> I have one question on xyplot() function.
>
> I am trying to produce a graph by this code.
>
> tmp <- data.frame(a=rnorm(20),
> b=rnorm(20),
> rho=factor(rep(1:2, c(10,10))),
> k=factor(rep(1:5,4)))
>
> tmp.lattice <-
> xyplot(a ~ b | rho*k, data=tmp,
> par.strip.text=list(font=5),
> strip=function(...) strip.default(..., strip.names=c(TRUE,TRUE)))
>
> names(tmp.lattice$condlevels) <- c("k","r")
> tmp.lattice
>
> You can see that on the strip, I have both k and rho in greek letters. I
> ONLY want rho to be greek letter and remain k as an ordinary lower case 'k'.
> The other question is, can I change the ":" into "=" in the strip? Thanks a
> lot.
>
> Zijiang
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Does this help?
library(lattice)
trellis.par.set(theme = col.whitebg())
tmp <- data.frame(a = rnorm(20),
b = rnorm(20),
rho = factor(rep(1:2, c(10,10))),
k = factor(rep(1:5,4)))
strip.math <- function(which.given, which.panel, var.name,
factor.levels, ...) {
vn <- var.name[which.given]
fl <- factor.levels
expr <- paste(vn, "==", fl, collapse = ",")
expr <- paste("expression(", expr, ")", sep = "")
fl <- eval(parse(text = expr))
strip.default(which.given, which.panel, vn, fl, ...)
}
xyplot(a ~ b | rho*k, data=tmp, strip = strip.math)
The "eval(parse(text = ...)))" is the only way I know how to build a
valid expression for the plotmath functions. See ?plotmath for more
information.
HTH,
--sundar
More information about the R-help
mailing list