I have two data frames one is a map with over 20000 possibilities, another one contains 3 columns of 30000 rows of data. I need to use the map to figure out the correct name. Here is a simple example of what I need:
For instance,
data <- data.frame(
V1 = c('baa','bb','aa','cc','dd','ee','caa'),
V2 = c('ff','gg','hh','yy','jj','kk','hh')
)
# V1 V2
# baa ff
# bb gg
# aa hh
# cc yy
# dd jj
# ee kk
# caa hh
map <- data.frame(
V1 = c('aa','gg','cc','jj','kk'),
V2 = c(1:5)
)
# V1 V2
# aa 1
# gg 2
# cc 3
# jj 4
# kk 5
>what.I.need
V1 V2 V3
baa ff 1
bb gg 2
aa hh 1
cc yy 3
dd jj 4
ee kk 5
caa hh 1
I tried using grep, but I can't seem to figure out how to make it work with a map of 20000 possibilities and have it populate the 3rd column in "what.I.need". Thank you in advance.