[R] panel.xyplot and panel.loess using two different groupings

Timothy W. Hilton thilton at ucmerced.edu
Tue Jan 27 19:19:06 CET 2015


Hello,

I have a dataset consisting of four variables: species (factor, five
levels), C3C4 (factor, two levels), and numeric variables PAR and LRU.
I wish to produce a scatter plot of PAR vs LRU where (1) each species
has a unique symbol and color (2) there is an overlaid loess line that
is calculated for each C3C4 level.  The following code produces a nice
plot where each species has its own loess curve, but I'm struggling for
the syntax to produce a single loess curve for all the points in each of
the two plots:

xy <- xyplot(LRU~PAR|C3C4, data=light_data, groups=species,
             panel=panel.superpose,
             auto.key=TRUE,
             col.line=pal,
             par.settings=mytheme,
             panel.groups=function(x, y, ...){
                 panel.xyplot(x, y, ...)
                 panel.loess(x, y, ...)})

Any help much appreciated.  Thanks!  
Tim

--

Timothy W. Hilton
Assistant Project Scientist
Sierra Nevada Research Institute
University of California, Merced
thilton at ucmerced.edu



More information about the R-help mailing list