[R] question on using lattice panel plots

Sundar Dorai-Raj sdorairaj at gmail.com
Thu Apr 16 22:20:11 CEST 2009


Try:

z <- cbind(rep(c("BIC", "hist"), each = 150), rep(rep(c(5, 10, 30),
each = 50),2))

z <- as.data.frame(z)

z <- cbind(z, runif(300))
names(z) <- c("Method", "sigma", "Error")
z$sigma <- factor(z$sigma, c("5", "10", "30"))
library(lattice)

sigma <- as.numeric(levels(z$sigma))
sigmaExprList <- lapply(sigma, function(s) bquote(sigma == .(s)))
sigmaExpr <- as.expression(sigmaExprList)
bwplot(Error~Method | sigma, data = z,
       horiz = F, xlab = "Method",
       strip = strip.custom(var.name = sigmaExpr,
         strip.levels = FALSE, strip.names = TRUE),
       layout = c(3,1))

HTH,

--sundar

On Thu, Apr 16, 2009 at 12:43 PM, Ranjan Maitra <maitra at iastate.edu> wrote:
> Hi,
>
> I think this question is best explained using the following
> self-contained toy example:
>
>
>
>
> ## cut code here and paste to R window
>
> z <- cbind(rep(c("BIC", "hist"), each = 150), rep(rep(c(5, 10, 30),
> each = 50),2))
>
> z <- as.data.frame(z)
>
> z <- cbind(z, runif(300))
>
> names(z) <- c("Method", "sigma", "Error")
>
> library(lattice)
>
> bwplot(Error~Method | sigma, data = z, horiz = F, xlab = "Method",
> layout = c(3,1))
>
>
> ## end code
>
>
>
>
> Now the question:
>
> I would like the panels to be in the order of sigma, i. e. 5, 10, 30
> and not 10, 30 and 5 as is currently the case. Is this possible?
>
> Not to seek too much indulgence, but to ask anyway, I wonder if it is
> possible to have a Greek sigma = 5, a Greek sigma = 10 and a Greek
> sigma = 30. (Sort of what we would get using expression(sigma == 5),
> expression(sigma == 10), expression(sigma == 10) on "base" R figures).
>
> Please let me know if my question is not clear.
>
> Many thanks for any suggestions and help and best wishes!
> Ranjan
>
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list