[R] how to match or merge data.frames in this case...
Paulo Cardoso
pecardoso at netcabo.pt
Thu Sep 4 02:17:23 CEST 2008
Hi,
I'm trying to match two data frames in order to replace the boundary values
in a dataframe.1 with values in dataframe.2 ONLY where the pair id1 id2
matches between the two data frames.
Eg.
> dataframe.1
... id1 id2 boundary
3307 1095 1108 438.691
3308 1095 1109 438.691
3309 1095 1121 438.691
3310 1096 1109 438.691
...
3345 1108 1120 438.691
3346 1108 1121 438.691
3347 1108 1133 438.691
3348 1109 1121 438.691
3349 1109 1122 438.691
3350 1109 1134 438.691
3351 1110 1122 438.691
...
3383 1121 1133 438.691
3384 1121 1134 438.691
3385 1121 1145 438.691
3386 1122 1134 438.691
> dataframe.2
id1 id2 boundary level sublevel
1 1095 1121 0 1 1
2 1095 1109 0 1 1
3 1095 1108 0 1 1
4 1108 1121 0 1 1
5 1108 1133 0 1 1
6 1109 1122 0 1 1
7 1109 1121 0 1 1
8 1109 1134 0 1 1
6 1109 1122 0 1 1
7 1109 1121 0 1 1
8 1109 1134 0 1 1
9 1121 1145 0 1 1
10 1121 1133 0 1 1
11 1121 1134 0 1 1
...
I'm not being able to reach this with %in% or merge
Thanks in advance,
Paulo
More information about the R-help
mailing list