I have the two following tables:
df <- data.frame(eth = c(\"A\",\"B\",\"B\",\"A\",\"C\"),ZIP1 = c(1,1,2,3,5)) Inc <- data.frame(ZIP2 = c(1,2,3,4,5,6,7)
Another option:
library(dplyr) library(tidyr) Inc %>% gather(eth, value, -ZIP2) %>% left_join(df, ., by = c("eth", "ZIP1" = "ZIP2"))