[R] Merge problem

From: Tova Fuller <suprtova_at_ucla.edu>
Date: Fri 22 Sep 2006 - 09:09:26 GMT


Hello all,

I have read as many merge issues as I possibly could tonight and although I presume this is a small error, I have not found the solution to my problem.

I'm trying to merge two data sets: dat0 and TransTable. As you can see below, dat0 has 8000 rows, whereas TransTable has 47296 rows. I would expect when I merge the two data sets, with all.x=F, and all.y=F, that the intersection would yield 8000 rows, considering dat0 is a subset of TransTable.

However, I get a neat little surprise when I check the dimensions of the resultant data frame - dat0merge, the merged data frame has 8007 rows! How can this be? Where did these extra 7 rows come from? This appears to defy logic!

Thank you in advance for your help. I've put my code below for reference.

Tova Fuller

> dim(dat0)

[1] 8000 60
> dim(TransTable)

[1] 47296 9
> dat0merge=merge(TransTable,dat0,

by.x="Target",by.y="TargetID",all.x=F,all.y=F)

> dim(dat0merge)

[1] 8007 68



R-help@stat.math.ethz.ch 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. Received on Fri Sep 22 19:11:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Sep 2006 - 10:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.