0

Let's assume two dataframes: A and B.

Dataframe: A              Dataframe: B
    ColA1    ColA2        ColB1  ColB2     
  | Dog   |   Peter|    | Lion |  Bob   |
  | Lion  |   Bob  |    | Cat  |  NA    |
  | Zebra |   Jim  |    | Tiger|  NA    |
  | Bat   |   Robin|    | Dog  |  Peter |

I want to to do this:

B$ColB2 <- ifelse((B$ColB1 %in% A$ColA1), "Name from col A" , NA)
Dino C
  • 307
  • 3
  • 15
  • 2
    [How to make a great R reproducible example?](http://stackoverflow.com/questions/5963269) – Sotos Sep 06 '17 at 13:15
  • It doesn't seem to be a duplicate. I m not interested in getting a subset. This indeed would be a duplicate. I want to locate the index of the matching and get the value of another column with this index. Please before marking a question as duplicate, revaluate the post. Thanks! – Dino C Sep 06 '17 at 14:58
  • 1
    What you describe is merging. You just need to specify the argument `all = TRUE`. Everything is explained in the duped link. – Sotos Sep 06 '17 at 15:36

0 Answers0