0

Lets say I have a data frame with IDs and other columns and I want to add a column showing whether or not an ID also exists in another data frame. If it does, the column should be a 1. If it doesn't, it should be a 0.

How can I do this using dplyr? I've played around using left_joins as well as mutate and ifelse but can't seem to find a quick solution.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
Rob
  • 1
  • `as.numeric(id %in% otherDataframe$column)` perhaps, but we really would like a reproducible example – Rich Scriven Aug 20 '15 at 23:55
  • Hi Richard, that works. Thanks! Sorry i am new to posting to this site so I am not sure what the etiquette is yet. Let me know if I should add to my question for others who might have a similar question. – Rob Aug 21 '15 at 00:02
  • This is a pretty good guideline to follow ;) http://stackoverflow.com/help/how-to-ask – Rich Scriven Aug 21 '15 at 00:07

0 Answers0