create unique ID for each group
I want to merge dat1 and dat2 based on "ID" in order
Have you tried merge(dat1, dat2) ? If ID is the common column (and no others), then that should be all you need to join (see ?merge). And then order if needed. Chris
Chris Stubben Los Alamos National Lab Bioscience Division MS M888 Los Alamos, NM 87545