[R] xyplot and panel.curve

Duncan Mackay mackay at northnet.com.au
Fri Oct 29 00:35:40 CEST 2010


Hi  All
I have regression coefficients from an experiment and I want to plot them 
in lattice using panel curve but I have run into error messages.
I want an 3 panel conditioned plot of 2 curves of Treatment 2 in each panel 
conditioned by Treatment1, the example curve expression is x+value*x^2
A rough toy example to give an idea of what I want is:

Data:
data = expand.grid(Treatment1 = LETTERS[1:3],Treatment2 = letters[1:2])
data$value =seq(1.1,1.6,0.1)
data
   Treatment1 Treatment2 value
1          A          a   1.1
2          B          a   1.2
3          C          a   1.3
4          A          b   1.4
5          B          b   1.5
6          C          b   1.6

xyplot(value|Treatment1, data = data,
          groups = Treatment2
          panel = function(value, groups){
                        panel.curve(expr = x+ value*x^2, groups, from = -2, 
to = 2)
                     }
)

I tried my one panel function but came up with more error messages so have 
omitted it.

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mackay at northnet.com.au



More information about the R-help mailing list