[R] xyplots with differentiated first data points

Russell Wyeth rustyconc at gmail.com
Fri Dec 16 06:00:30 CET 2011


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


-- 

Russell Wyeth
Biology, St Francis Xavier University
P.O. Box 5000 Antigonish, NS B2G 2W5 Canada
Shipping: 1 West St. Antigonish, NS B2G 2W5 Canada
http://people.stfx.ca/rwyeth/
Ph: 9028673886 Fx: 9028672389
Cell: 9023180250



More information about the R-help mailing list