0

Sorry if this is terribly formatted, I'm still getting used to this site and learning how to do things in R. Sorry if this is an obvious question also, but I tried a lot of different things and looked up similar questions and answers and still couldn't figure this out :(

I want to merge the data.frames (frame1 and frame2) by columns V1 and VB, keeping the rows that match, but excluding the rows that don't the get something like frame3.

frame1

V1    V2
A     1a
B     2a
C     3a
D     4a

frame2

VA    VB    VC
1     A     15
2     B     14
3     C     13
4     AA    12
5     BB    11
6     D     10

frame3

V1VB   V2    VA    VC
A      1a    1     15
B      2a    2     14
C      3a    3     13
D      4a    6     10

I tried:

test <- merge(frame1, frame2, by.x='V1',by.y='VB',all=FALSE)
test

But I'm not getting my intended result.

Thank-you for all your help!

user5987132
  • 55
  • 1
  • 1
  • 7
  • 1
    remove **all = FALSE** – Sangram Jun 07 '16 at 19:44
  • I guess you need `all.x = TRUE` – Jaap Jun 07 '16 at 19:51
  • You should look here: http://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right/1300618#1300618 – Miha Jun 07 '16 at 20:01
  • `frame1` and `frame2` have no row or column in common. Name VB => V1 and it should work. See [here](http://www.dummies.com/how-to/content/how-to-use-the-merge-function-with-data-sets-in-r.html) for explenations. – Christoph Jun 08 '16 at 09:00

0 Answers0