[R] Merging multiple data sets
cddesjar
cddesjardins at gmail.com
Thu Jun 23 18:53:21 CEST 2011
Hi,
I am trying to merge data similar to the example data below
> dat0
id var1 var2 var3
2 1 0 1
3 1 0 1
4 0 1 1
5 0 1 1
> dat1
id var4 var5 var6
2 1 0 1
3 1 0 1
6 0 1 1
7 0 1 1
> dat2
id var7 var8 var9
2 1 0 1
5 1 0 1
6 0 1 1
8 0 1 1
Basically what I'd like to do is combine these variables on id and create
one large data frame that looks like the following.
> dat3
id var1 var2 var3 var4 var5 var6 var7 var8 var9
2 1 0 1 1 0 1 1 0
1
3 1 0 1 1 0 1 NA NA
NA
4 0 1 1 NA NA NA NA NA NA
5 0 1 1 NA NA NA NA NA NA
6 NA NA NA 0 1 1 0 1 1
7 NA NA NA 0 1 1 NA NA NA
8 NA NA NA NA NA NA 0 1 1
How can I best do this in R? I've looked into merge but it excludes ids that
aren't in all 3 data sets.
--
View this message in context: http://r.789695.n4.nabble.com/Merging-multiple-data-sets-tp3620431p3620431.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list