Skip to content
Prev 280366 / 398506 Next

xyplots with differentiated first data points

Hi,

I'm trying to plot a series of lines without data point markers, except 
for the first data point in each line, which I want to also mark with an 
open circle.

The following code accomplishes this for a single line:

xyplot(yy ~ xx,
          panel=function(x, y){
             panel.xyplot(x, y, col="black",type="l")
             panel.xyplot(x[1], y[1], col="black",type="p")
         })

However, I am trying to do this for every line for multiple lines in a 
panel, with several panels created by a 'by()' function (I do not want a 
grid of panels, I want separated panels).

expt1 is a dataframe with seven factor columns, and x,y data coordinates 
in columns 8 and 9.

I can appropriately create the grouped lines  (but without the single 
data markers) with following code:

by(expt1,expt1[,3:4],function(q) xyplot(q[,9] ~ q[,8], groups=q[,2], 
data=q, col="black", type="l"))

But I am stuck putting the two goals together because I can't figure out 
how to get the group information to be properly passed to the custom 
panel function above.

I suspect I may be going about this entirely the wrong way - I've been 
using R for all of 4 hours...

Help appreciated.

Russell