0

I am using R. I have two tables, both with an ID variable. I want to make another table where I have a column for ID which only has IDs that appear in both original tables, plus a column for another variable that only appeared in one of the original tables.

Any help would be much appreciated.

amelia28
  • 1
  • 1
  • This is a very common question, the default settings of the base R `merge` function will work fine. Have a look at the help page: `?merge`. In the future, please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example-aka-mcve-minimal-complete-and-ver), but first spend some time searching for similar questions. – lmo Nov 28 '17 at 12:37

1 Answers1

1

Try this

library(dplyr)
df_temp <- inner_join(df_1, df_2, by=ID)
df_3 <- subset(df_temp, select = c(ID, OtherColumn))
Barbara
  • 1,118
  • 2
  • 11
  • 34