0

I have a data set with a unique alphanumeric identifier and associated information: a quality score [1-5], island abbreviation, etc.

ex.

UniqueID  Score  Island1  Island2  

MSI1234     1     MSI      MSI

MSI4567     4     MSI      EER

MSI456789   3     MR       MSI

I have a second data set with unique alphanumeric identifiers and known sex information.

ex.

UniqueID    Sex

MSI1234      F

MSI124011    F

MR2344       M

Some of the individuals in the second data set will have information in the first data set. I would like to create a third data set of individuals found in both datasets. I would like all of the information in the first data set plus a column for sex.

ex.

  UniqueID  Score  Island1  Island2  Sex

  MSI1234     1     MSI      MSI      F

Is there a way to do this in R or excel? I'm open to any option, but I'm new to this kind of data manipulation.

Thanks!!

Quinn
  • 59
  • 6
  • Just use `merge` `merge(df1, df2, by = 'UniqueID')` – akrun Jan 15 '20 at 20:46
  • Thanks for the input. However, I tried this and it returned more rows than it should have. I think the issue is that I don't want to just merge the data sheets. I want a new data sheet with rows only for UniqueIDs that are in both of the original two data sheets. Am I missing something? – Quinn Jan 16 '20 at 15:10
  • From the example showed, I get exactly the same output as your expected – akrun Jan 16 '20 at 18:37

0 Answers0