[R] two questions re: the use of lattice (Q1 SOLVED, not Q2)

Ranjan Maitra maitra.mbox.ignored at inbox.com
Sun Jul 22 18:02:37 CEST 2012


Dear friends,

Many thanks to Jim (Holtman) and David (Carlson) for their quick
responses: Q1 is now solved. There are two almost equivalent ways for
doing this. They follow:
library(lattice)

z <- rbind(cbind(z, 0), cbind(z, 20), cbind(z, 40))
z <- cbind(z, rnorm(n = nrow(z)))
z <- as.data.frame(z)
names(z) <- c("Method", "sigma", "INU", "Error")
sigma <- as.numeric(levels(z$sigma))
sigmaExprList <- lapply(sigma, function(s) bquote(italic(sigma) == .
(s))) sigmaExpr <- as.expression(sigmaExprList)

z$Method <- factor(z$Method, levels = c("BIC", "ICL", "s_v", "Q_v", 
  "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", "s_haar"))

bwplot(Error~Method | sigma, data = z[z[,"INU"] == 0,
                               ],scales=list(rot=90),
       horiz = F, xlab = "Method", ylab = "Relative Error",
       strip = function(which.given, which.panel, var.name,
         strip.levels = FALSE,
         strip.names = TRUE, ...) {
         strip.default(which.given, which.panel,
                       var.name = sigmaExpr[which.panel],
                       strip.levels = FALSE,
                       strip.names = TRUE, ...)
        },
        layout = c(1, 5),  col = "red")

# On the other hand, if we do not want to change z$Method in perpetuity, we could do the following: 


z <- cbind(rep(c("BIC", "ICL", "s_v", "Q_v", "sig-q",
                      "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8",
"s_haar"), each = 250), rep(c(5, 10, 20, 30, 50), each = 50))
z <- rbind(cbind(z, 0), cbind(z, 20), cbind(z, 40))
z <- cbind(z, rnorm(n = nrow(z)))
z <- as.data.frame(z)
names(z) <- c("Method", "sigma", "INU", "Error")
sigma <- as.numeric(levels(z$sigma))
sigmaExprList <- lapply(sigma, function(s) bquote(italic(sigma) == .
(s))) sigmaExpr <- as.expression(sigmaExprList)

bwplot(Error~factor(Method, levels = unique(Method)) | sigma, data = z[z
[,"INU"] == 0, ],scales=list(rot=90),
       horiz = F, xlab = "Method", ylab = "Relative Error",
       strip = function(which.given, which.panel, var.name,
         strip.levels = FALSE,
         strip.names = TRUE, ...) {
         strip.default(which.given, which.panel,
                       var.name = sigmaExpr[which.panel],
                       strip.levels = FALSE,
                       strip.names = TRUE, ...)
        },
        layout = c(1, 5),  col = "red")



# However, I am unable to solve Q2. Actually, even more basic is the fact that I can not get Box-Whisker plots without anything else. David's suggestion of using useOuterStrips appears reasonable, but as I said, I can not get anything meaningful even before then. 

# Try:

bwplot(Error~Methods | sigma + INU, data = z,scales=list(rot=90))

Any suggestions?

Many thanks again!

Best wishes,
Ranjan

____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails



More information about the R-help mailing list