[R] Merge more than 2 dataframe

arun smartpink111 at yahoo.com
Mon Dec 17 20:42:55 CET 2012


Hi, 
You could use either: 
Reduce(function(...) merge(...,by="date"),list(dat1,dat2,dat3,dat4)) 
#or 
library(reshape) 
merge_recurse(list(dat1,dat2,dat3,dat4), by="date") 
A.K.   



----- Original Message -----
From: Vasilchenko Aleksander <vasilchenko.a.p at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Monday, December 17, 2012 11:03 AM
Subject: [R] Merge more than 2 dataframe

Hello.
I have for example 4 or more dataframe which like such this example:
  date      value
2006-11 0.4577647
2006-12       NaN
2006-10 0.1577647
2006-11 0.3577647
2006-12       NaN
2007-01       NaN
2007-02       NaN
2007-03 0.2956429
2007-01 0.3677647
2007-02       NaN
They have the same length. I need merge by date undefined number of
dataframes. End result output will look like such example
  date      name1          name2      name3         name4   ....
2006-11 0.4577647     0.4577647   0.4577647  NaN
2006-12       NaN        NaN           0.4577647  0.4577647
2006-10 0.1577647     0.1577647   0.4577647  NaN
2006-11 0.3577647     0.8577647   0.4577647  0.4577647
2006-12       NaN        0.1577647   0.4577647  0.4577647
2007-01       NaN        0.2277647   NaN           0.1777647
2007-02       NaN        0.4577647   0.4577647  0.4477647
2007-03 0.2956429     NaN            0.4577647  0.1577647
2007-01 0.3677647     0.4577647   NaN7         0.4577647
2007-02       NaN        0.6577647   0.4577647  0.4577647

Sincerely yours,
Aleksander

______________________________________________
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.





More information about the R-help mailing list