[R] panel.linejoin groups

Erin Berryman berr0179 at umn.edu
Fri Sep 23 20:26:28 CEST 2005

Both methods you listed do work, but type='l' is what I want, thank you 
for pointing that out to me. Incidentally, xyplot(type='l') printed 
much faster on the display than the panel.groups=() method. I was 
captivated by linejoin before I ever had a case to use 
xyplot(type='l'), which would explain why I tried to use it for this 
type of plot!

On Sep 23, 2005, at 1:01 PM, Deepayan Sarkar wrote:

> On 9/23/05, Erin Berryman <berr0179 at umn.edu> wrote:
>> Dear R community,
>> I am still new to R, but I am attempting to use it for (hopefully) all
>> my plotting needs. I have been using lattice and Hmisc for most plots
>> so far successfully, but I need help creating a plot I desire for some
>> new data I have.
>> This data frame consists of the same type of measurement (Eh) for 27
>> different locations. I have 8000+ measurements for each location, and
>> my datalogger organizes the output like this:
>> Date                                    A1L                     A2L   
>>                   A3L
>> 2005-07-14 22:00                208.1           -178.5          196.8
>> 2005-07-14 22:10                207.9           -184.3          200.0
>> Now I'm having trouble plotting A1L, A2L, A3L on the same plot as a
>> function of Date. I thought I would try panel.linejoin, like so:
>> xyplot(data=redox2, A1L + A2L + A3L ~ Date,
>> panel=function(x,y,...){panel.linejoin(x,y,horizontal=F,col=1,...)},
>> scales=list(x=list(tick.number=10)))
>> But of course, what I get is the mean of the measurements from those
>> three columns plotted as one line, when what I want is a separate line
>> for each column of data. Do I need to define "groups" somehow to get
>> separate lines? If so, how do I define groups based on membership in
>> different columns? Or do I just need to reorganize my data to make it
>> work, like this:
>> Date                            Location                Eh
>> 2005-07-14 22:00        A1L                     208.1
>> 2005-07-14 22:00        A2L                     -178.5
>> Then I can define groups=Location, and it would work.  But it would be
>> good to know if I can make the data work as is - because I have many
>> many more datasets that are structured this way.
> Yes, simply supply 'panel.groups' instead of 'panel'
> panel.groups = function(x,y,...) { 
> panel.linejoin(x,y,horizontal=F,col=1,...) },
> panel.linejoin doesn't know anything about groups, and has to be used
> through panel.superpose (which does). However, the more obvious
> approach seems to be
> xyplot(A1L + A2L + A3L ~ Date, data=redox2,
>        type = 'l',
>        scales=list(x=list(tick.number=10)))
> Does that not work? panel.linejoin is meant for cases where several
> observations need to be summarized by a single number (mean, median,
> etc).
> BTW, it's not a good idea to have anything other than the formula as
> the first argument to xyplot etc.
> Deepayan
Erin M. Berryman
Graduate Research Assistant
Department of Soil, Water, and Climate
University of Minnesota

More information about the R-help mailing list