Skip to content
Prev 207662 / 398513 Next

Bulk Match/Replace

This must be easy to do.....

I have a vector and a lookup data.frame:

 > v
   [1] "5"   "234"   "234"   "42-43"   "234"   "42-43"   "234"   "234"   
"42-43"   "234"   "5"   "234"   "234"   "5"   "234"   "234"   "5"   
"234"   "234"
 > df
   id  Name
1         5 12-13
2         2   234
3         4 42-43
4         1     5

How can I simply substitute the values in vector v with the 
corresponding id value from lookup table df? I'd expect the following 
output:
 > v
   [1] "1"   "2"   "2"   "4"   "2"   "4"   "2"   "2"   "4"   "2"   "1"   
"2"   "2"   "1"   "2"   "2"   "1"   "2"   "2"

Cheers,
Nathan