[R] Merge problem

Tova Fuller suprtova at ucla.edu
Fri Sep 22 11:09:26 CEST 2006


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



More information about the R-help mailing list