[R] replace values in one df by values from key pairs in another df

arnaud gaboury arnaud.gaboury at gmail.com
Fri Feb 13 13:02:53 CET 2015


This is the wrong part of my code.

>
>> idName=users[users$id %in% ext]
>           id        name
> 1: U03AEKWTL agreenmamba
> 2: U032FHV3S   poisonivy
> 3: U03AEKYL4      vairis
>

Best is to use:

idNames <- users[pmatch(ext, users$id, duplicates.ok = T)]. This leave
me with an ordered and duplicate entries :

> idNames <- users[pmatch(ext, users$id, duplicates.ok = T)]
          id        name
1: U03AEKYL4      vairis
2: U03AEKYL4      vairis
3: U03AEKWTL agreenmamba
4: U032FHV3S   poisonivy



More information about the R-help mailing list