[R] Access to conditioning values in xyplot

2006-07-13 Thread Jean-Marc Ottorini

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:

- the arguments  packet.number = di, panel.number must appear on the 
panel function prototype
- a, b, a1, b1 are parameters set to a certain value before calling 
xyplot
- unique is needed to reduce to 1 the multiple instances of the value 
of the conditioning variable di for a given panel (one for each point)
- I was surprised by the need to use rev in order for the interval of 
the values to draw the curve  f.fit to correspond to the right panel.

Any further comment would be welcome

Best regards

Jean-Marc
  
Jean-Marc Ottorini   LERFoB, UMR INRA-ENGREF 1092
  email  [EMAIL PROTECTED]  INRA - Centre de Nancy
  voice  +33-0383-394046F54280 - 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


[R] Access to conditioning values in xyplot

2006-07-12 Thread Jean-Marc Ottorini
Dear all,

   I have already searched unsuccessfully a lengthy R documentation, the 
archives of the list,  and the Internet for a solution to this 
problem... Could anybody, please, have a look at it?

The following  lattice graphics works well:


   residus - 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) {
   panel.grid(h = -1, v = -1, col = grey, lwd = 1, 
lty = 1)
   ## --
   ## panel.curve(expr, from, to, n = 101, 
curve.type = l, ...)
   ## --
   panel.superpose(x, y, pch = c(1, 2), col = 
c(red,blue), panel.groups = panel.xyplot, subscripts, groups)
 },
 key = list( space = top, transparent = TRUE, 
columns = 2,
   points = list( pch = c(1, 2), col = c(red, 
blue) ),
   text = list( c(bloc 3, bloc 4))),
 )


So far, so good, nothing tricky here...


Now I would like to uncomment this code to draw the line fitted to the 
points in each panel using panel.curve (expr = f(x, di, ...), where 
the function f is already known (i.e. has been fitted), depends on x, 
as needed, * but also on the value di for each panel of the 
conditioning variable di *, which I have no idea as how to access it...

Many thanks for your time...

Jean-Marc

  
Jean-Marc Ottorini   LERFoB, UMR INRA-ENGREF 1092
  email  [EMAIL PROTECTED]  INRA - Centre de Nancy
  voice  +33-0383-394046F54280 - Champenoux
  fax+33-0383-394034 France


  
Jean-Marc Ottorini   LERFoB, UMR INRA-ENGREF 1092
  email  [EMAIL PROTECTED]  INRA - Centre de Nancy
  voice  +33-0383-394046F54280 - 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


Re: [R] R-help Digest, Vol 30, Issue 26

2005-08-26 Thread Jean-Marc Ottorini
Dear R helpers,

   For me ( i.e. R 2.1.1 on Mac OS X), using  trellis.device 
(postscript, onefile = F, etc ...  with the lattice library within a R 
function works fine to obtain the desired graph as an EPS file , 
provided that :

1) the command dev.off() is not included in this function

2) and it is  issued at the  command level after the function has 
been exited

I would like to know if there is a way to close the EPS file within the 
function itself, freeing the user to issue the closing command (I 
already  tried trellis.device (), and trellis.device (null) without any 
success).

Regards,

J.-M.

  
Jean-Marc Ottorini   LERFoB, UMR INRA-ENGREF 1092
  email  [EMAIL PROTECTED]  INRA - Centre de Nancy
  voice  +33-0383-394046F54280 - 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