[R] Match data.frames with different number of rows
Bernd Weiss
bernd.weiss at uni-koeln.de
Wed Nov 5 12:25:19 CET 2003
Dear all,
I have two data.frames a and b:
i <- c(1,1,2,2,3,3,4,4)
x <- c(1,53,7,3,4,23,6,2)
a <- data.frame(i,x)
and
j <- c(1,2,3,4)
y <- c(99,88,77,66)
b <- data.frame(j,y)
So, a looks like this
> a
i x
1 1
1 53
2 7
2 3
3 4
3 23
4 6
4 2
and b like this
> b
j y
1 99
2 88
3 77
4 66
Now, I would like to match 'b' to 'a', so that a new data.frame 'c' is
> c
i x z
1 1 1 99
2 1 53 99
3 2 7 88
4 2 3 88
5 3 4 77
6 3 23 77
7 4 6 66
8 4 2 66
I habe absolutely no idea how to do this. I searched the net, the FAQ, the manuals, my
four books...
Any help would be appreciated!
Bernd
More information about the R-help
mailing list