-4

I have two data frames like so:

A    B
1    6
2    7
5    4
3    3
9    9

and the other one:

A    C
1    5
5    9
3    1
9    1

and I want to merge them to create

A    B    C
1    6    5
5    4    9
3    3    1
9    9    1

notice that in the merged version, there is no A=2 because this does not show up in the second data frame (even though it shows up in the first). So basically, I want it to merge what exists, and leave out what doesn't. Currently, the merge fails completely because the two A columns are not exactly the same.

CodeGuy
  • 27,591
  • 71
  • 194
  • 314
  • see http://stackoverflow.com/questions/1299871/how-to-join-data-frames-in-r-inner-outer-left-right – Chase Oct 11 '11 at 11:34

1 Answers1

4
df2 <- data.frame(A=c(1,5,3,9), C=c(5,9,1,1))
df1 <- data.frame(A=c(1,2,5,3,9), B=c(6,7,4,3,9))
merge(df1,df2)
Anthony Pegram
  • 119,149
  • 26
  • 217
  • 245
Brandon Bertelsen
  • 42,225
  • 33
  • 153
  • 250