Possible Duplicate:
Merge multiple data frames in a list simultaneously
example data.frames:
df1 = data.frame(id=c('1','73','2','10','43'),v1=c(1,2,3,4,5)) <br>
df2 = data.frame(id=c('7','23','57','2','62','96'),v2=c(1,2,3,4,5,6)) <br>
df3 = data.frame(id=c('23','62'),v3=c(1,2)) <br>
Note: id is unique for each data.frame. I want the resulting matrix to look like
1 1 NA NA
2 3 4 NA
7 NA 1 NA
10 4 NA NA
23 NA 2 1
43 5 NA NA
57 NA 3 NA
62 NA 5 2
73 2 NA NA
96 NA 6 NA
In this case, I only show 3 datasets, I actually have at least 22 of them so at the end I want a matrix of nx(22+1) where n is the number of ids for all 22 datasets.
Given 2 datasets, I need to get their ids in the first column and 2nd and 3rd columns are filled with the values, if there is no value exists, then input NA instead.
Put them into a
listand usemergewithReduceYou can also use this more concise version: