0

I'm trying to add a column to a data.frame in R with a look-up table. Essentially I have two data.frames, and both of them have one column which is similar. I need to create a new column in the first data.frame from the reference table, but I don't want to merge the data.frames and create more rows. I need to just add another column in the first data.frame. This makes more sense if you look at the data.. enter image description here

So After the transformation I would like the organism column from the second data.frame to be in the first data.frame where the ORDER.TEST.MNEMONIC is a identical match. This seems like it should be trivial with R but I cannot seem to do it without creating additional rows with a merge. Any ideas are greatly appreciated, thanks

data should look like this... enter image description here.

EDIT: I now realize that when you merge with a look-up table and there are multiple references for an element that 'R' will create multiple rows to satisfy each look-up variable. So the reason a merge wasn't giving me the expected result is because 'R' was creating a new row for each look-up variable that meets a specific requirement. Thanks for pushing me in the correct direction.

Nodedeveloper101
  • 421
  • 1
  • 9
  • 24
  • #1 Please use `dput` to provide example data instead of screenshots, it makes things easier, and #2 in what way did `merge(data, ref.complete)` not satisfy you? – lukeA Jan 07 '16 at 20:28
  • The column have duplicate elements in both datasets – akrun Jan 07 '16 at 20:28
  • Please give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610) – Jaap Jan 07 '16 at 21:19

0 Answers0