[R] Access to conditioning values in "xyplot"

From: Jean-Marc Ottorini <ottorini_at_nancy.inra.fr>
Date: Thu 13 Jul 2006 - 21:51:48 EST

Dear R-help subscribers,

    Many thanks for all the answers I received either by mail or through the list, and that were most helpful.

  For the sake of the list records, I wanted to post the solution, I eventually could obtain, to the problem I have submitted.

  I am summarizing the question here. It was how to use the panel function "panel.curve" when the expression used in this function to to add a fitted line to the points in each panel depends not only on x, but also on the value of the conditioning variable for the considered panel.

This solution is based on hints given to me by Deepayan Sarkar, it relies on the use of "packet.number" and "panel.number":

xyplot(n ~ cg | di, data = myData,

        scale = list(y = "free", x = "free"),
        groups = bloc,
        as.table = T,
        xlab = "Cg",
        ylab = "N / ha",
        panel = function(x, y, subscripts, groups, packet.number = di, 
panel.number, ...) {
          panel.grid(h = -1, v = -1, col = "grey", lwd = 1, lty = 2)
          panel.curve(expr = 
f.fit(unique(rev(packet.number))[panel.number], a, b, a1, b1, x),
                      n = 50, curve.type = "l", col = "lightblue", ...)
          panel.superpose(x, y, pch = c(1, 2), col = 
c("deeppink","blue"),
                          panel.groups = "panel.xyplot", subscripts, 
groups)
        },

        key = list( space = "top", transparent = TRUE, columns = 2,
          points = list( pch = c(1, 2), col = c("deeppink", "blue") ),
          text = list( c("bloc 3", "bloc 4"))),
        )

Some comments:

Any further comment would be welcome

Best regards

Jean-Marc
  ----
Jean-Marc Ottorini               LERFoB, UMR INRA-ENGREF 1092
  email  ottorini@nancy.inra.fr          INRA - Centre de Nancy
  voice  +33-0383-394046                    F54280 - Champenoux
  fax    +33-0383-394034                                 France

______________________________________________
R-help@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 Received on Thu Jul 13 22:08:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 14 Jul 2006 - 04:14:19 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.