[R] Merge two dataframes of different column length and row length by two columns at a time
Gunther Höning
gunther.hoening at ukmainz.de
Fri Jul 21 09:33:56 CEST 2006
Hello,
I have two dataframes of the following structures:
str(a)
`data.frame': 1354896 obs. of 14 variables:
$ V1 : int 0 1 2 3 4 5 6 7 8 9 ...
$ V2 : int 0 0 0 0 0 0 0 0 0 0 ...
$ V3 : int 74 12305 103 12337 46 57 12446 90 12097 79 ...
$ V4 : num 11.8 1529.2 17.8 1579.4 6.7 ...
$ V5 : int 88 11040 104 11557 56 58 11040 74 10991 81 ...
$ V6 : num 15.5 1921.3 20.3 1888.2 12.6 ...
$ V7 : int 87 8793 90 10142 67 64 9264 73 8589 71 ...
$ V8 : num 16.0 1750.6 15.2 1783.7 11.0 ...
$ V9 : int 68 11279 93 11831 43 61 11234 82 10919 76 ...
$ V10: num 11.5 1999.5 39.0 1842.2 5.0 ...
$ V11: int 110 12456 92 12063 60 59 12393 82 11831 77 ...
$ V12: num 21.4 1974.7 33.9 1689.9 10.6 ...
$ V13: int 81 10887 101 10874 62 74 11115 79 10789 93 ...
$ V14: num 19.5 1812.3 31.7 1524.1 11.9 ...
> str(b)
`data.frame': 1213901 obs. of 4 variables:
$ V1: int 0 1 2 3 5 6 7 8 9 10 ...
$ V2: int 0 0 0 0 0 0 0 0 0 0 ...
$ V3: Factor w/ 54676 levels "str23","str53",..: 54676 54676 54676 54676
54676 54676 54676 54676 54676 54676 ...
$ V4: Factor w/ 3 levels "Match","NoMatch",..: 2 2 2 2 2 2 2 2 2 2 ...
>
I want to merge these dataframes by V1 and V2 of a and b. The combination of
V1, V2 is a unique key.
Note that b is smaller than a.
Any suggestions to solve this problem ?
Gunther Höning
Diplom Physiker
Bioinformatiker
Langenbeckstraße1
55131 Mainz
gunther.hoening at ukmainz.de
More information about the R-help
mailing list