[R] merging data frames

Srinivas Iyyer srini_iyyer_bio at yahoo.com
Sat May 17 02:14:57 CEST 2008


Dear group, 
I have 3 different data frames. I want to merge all 3
data frames for which there is intersection.

Say DF 1 and DF2 has 100 common elements in Column 1. 

DF3 does not have many intersection either with DF1 or
with DF2. 

For names in column 1 not present in DF3 I want to
introduce NA. 
DF1:
Name   Age
A       21
B       45
C       30

DF2:
Name   Age
A       50
B       20
X       10

DF3:
Name   Age
B       40
Y       21
K       30

I want to merge all 3 into one:


Df4:

Name.1    Age.1  Age.2  Age.3
A         21       50     NA  
B         45       20     40
C         30       NA     NA
K         NA       NA     30
X         NA       10     NA
Y         NA       NA     21


Could any one help me how can I merge 3 dataframes. 

appreciate your help. Thank you. 

srini



More information about the R-help mailing list