I would like to replace only a part of a set in R.
Specifically I need to replace the values of a column variable; Let say ds
has col1
which takes values like A, B, C, D, E
which I want to replace with some different values like 1,15, L1100, PQ7, 243
(some random distinct things).
For example, I want to replace few values not all eg. replace only A, B, C
by '1','15', 'L1100'
and D, E
will remain as it is. Most importantly, I don't want to merge to get this done. I want without merging solution like in python replace function which is very elegant.
ds['col1'].replace(['A','B', 'C', 'D', 'E'],['1','15', 'L1100', 'PQ7', '243'],inplace=True)