[R] merging data frames

From: Srinivas Iyyer <srini_iyyer_bio_at_yahoo.com>
Date: Fri, 16 May 2008 17:14:57 -0700 (PDT)


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



R-help_at_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. Received on Sat 17 May 2008 - 00:20:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 17 May 2008 - 04:30:38 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.

list of date sections of archive