Is there an alternative to “revalue” function from plyr when using dplyr?

后端 未结 4 1102
野性不改
野性不改 2021-02-18 16:05

I\'m a fan of the revalue function is plyr for substituting strings. It\'s simple and easy to remember.

However, I\'ve migrated new code to

4条回答
  •  无人共我
    2021-02-18 16:45

    One alternative that I find handy is the mapvalues function for the data.tables e.g

    df[, variable := mapvalues(variable, old = old_names_string_vector, new = new_names_string_vector)]
    

提交回复
热议问题