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

Ranjan Maitra maitra.mbox.ignored at inbox.com
Mon Jul 23 03:03:14 CEST 2012


> >> [I had to dig back to see what your Q2 was. It's good to keep context.]
> >>
> >> Try this:
> >>
> >>    p <- bwplot(Error~Method | sigma + INU, data = z,
> >>           scales = list(rot=90), horiz = FALSE,
> >>           layout = c(5,3), col = "red")
> >>
> >>    require(latticeExtra)
> >>    useOuterStrips(p,
> >>         strip = <<your sigma-strip function>>,
> >>         strip.left = strip.custom(
> >>             var.name = "INU", sep = " = ",
> >>             strip.names = TRUE)
> >>    )
> >>
> >
> > This works!! Thanks very much!! May I also ask how I can put in a "%"
> > after the INU value? i.e., I want the labels to be INU = 0%, INU = 20%,
> > INU = 40% (instead of INU = 0, INU = 20 and INU = 40).
> 
> Define:
> 
>    INUExpr <- paste0("INU = ", c(0,20,40), "%")
> 
> Then
> 
>      useOuterStrips(p,
>         strip = <<your sigma-strip function>>,
>         strip.left = << your strip function with
>                var.name = INUExpr[which.panel] >>
>    )
> 
> Peter Ehlers

Thanks, Peter! I have been trying things like this all afternoon. But i
still get the same problem:

The following, from your earlier e-mail works (cut-and-paste should be
fine):


library(lattice)
library(latticeExtra)
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)



p <- bwplot(Error~factor(Method, levels = unique(Method)) | sigma +
INU, data = z, scales = list(rot=90), horiz = FALSE,
         layout = c(3,5), col = "red")

  require(latticeExtra)

  useOuterStrips(p,
       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, ...)
        },
                 strip.custom(
                              var.name = "INU", sep = " = ",
                              strip.names = TRUE))



However, this (edition of the latter) does not:

INUExpr <- paste0("INU = ", c(0,20,40), "%")

  useOuterStrips(p,
       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, ...)
        },
       strip.left = function(which.given, which.panel, var.name,
         strip.levels = FALSE,
         strip.names = TRUE, ...) {
                 strip.custom(
           var.name = INUExpr[which.panel],
           strip.names = TRUE, ...)
               }
  )


Clearly, I am doing something wrong in defining the strip function. (It
does not help that i am not completely at home with it.)  Can you or
someone please help some more?

Many thanks again!
Best wishes,
Ranjan

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list