Hey All, I have a dataset(dat1) like this:
ObsNumber ID Weight 1 0001 12 2 0001 13 3 0001 14 4 0002 16 5 0002 17 And another dataset(dat2) like this: ID Height 0001 3.2 0001 2.6 0001 3.2 0002 2.2 0002 2.6 I want to merge dat1 and dat2 based on "ID" in order, I know "match" only returns the first match it finds. So I am thinking create unique ID col in dat2 and dat2, then merge. But I dont know how to do that so it can be like this: dat1: ObsNumber ID Weight UniqueID 1 0001 12 0001_1 2 0001 13 0001_2 3 0001 14 0001_3 4 0002 16 0002_1 5 0002 17 0002_1 dat2: ID Height UniqueID 0001 3.2 0001_1 0001 2.6 0001_2 0001 3.2 0001_3 0002 2.2 0002_1 0002 2.6 0002_2 Or if it is possible to merge dat1 and dat2 by matching "ID" but return the match in order that would be great! Thanks for your help! [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.